is there any way to set focus on the input field without showing keyboard on a device? The code is shared across the website and the mobile device. I just want to acquire situation when on a website I got "focus" on the input element as well as on device but without displaying a keyboard on the device. I tried:
document.getElementById("myInput").focus();
but doesn't work.
Why do you want to focus an input field if you don't want to write in it? Otherwise you can check with
var isMobile = Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
if the user agent is mobil before you take the focus.
It's a normal behavior of device.
You can use some cordova plugin (like this cordova-plugin-keyboard) to hide the keyboard.
Don't forget to check out if the user agent is from a mobile device
Anyway, it's the behavior of device, hide the keyboard will make your application act different from the others
Related
I'm trying to get access to the mobile keyboard in a cordova app so that while the user is signing up, they can just jump to the next input on the keyboard. For example, on iOS native apps, you have access to change the "return" button to "next" or "go."
I've looked at the Ionic-plugin-keyboard but as far as I can see it doesn't allow you to do what I'm trying to do. Is there a way I can change those buttons with js/is there another plugin I can do that with?
Here are some potential resources for keyboard control:
link 1
link 2
link 3
In summary: On most devices it show a "next" button when adding the attribute tabindex to each input, incrementing in order. Otherwise it is generally suggested to set an input as the browser's default focus, or to detect when the user clicks "ok" and move the focus after that event (key code for "ok"/"enter" is 13).
I'm trying to use an input text box as a URL sharing widget. Fairly standard: when you click on the textbox, all of the text inside is automatically highlighted to make it easy to copy and paste. It's set as read-only='read-only' to prevent the user from changing the URL accidentally, and the click event is set to this.focus();this.select();. This works on the desktop.
The problem arises with Safari Mobile (I'm using iOS 7.0.6). From what I can tell, the read-only prevents using the standard setSelectionRange(0,9999);. But if I turn off read-only and just use javascript to prevent editing, the iOS keyboard shows once the text input has focus.
tl;dr On Safari Mobile I'd like to have the uneditable textbox be entirely selected on focus but without showing the keyboard (ideally it would show the copy/paste menu too, but I think that's a stretch). Is this possible?
JSFiddle shamelessly forked from this answer:
JSFiddle showing input with read-only set (Doesn't work on Safari Mobile iOS 7.0.6)
In my Phonegap application i need one div which is scrollable, When user click on it device keyboard should be open and text should be writeable in div. But i dont know how to open device native keyboard for both device. Is there any plugin available for this functionality.
Have a hidden input field, and onclick event of that div, simply call focus() for that input field. It'll automatically bring up the keyboard. And then you can read the content of the input field and write that into the div.
I am using phonegap to develop a web app for Android, and since I will have my own keypad in HTML, I need to disable android's system keyboard, preventing the it from showing up when the user clicks on any text input field. I don't want to use readonly input field or onblur() since I would like to have the cursor in the text filed so user can move the cursor position while they're entering inputs.
So I want to completely disable Android's keyboard on default, I tried adding android:windowSoftInputMode="stateAlwaysHidden" to manifest.xml but this does not work.
I also try use a javascript interface from here, but there was a javascript-java bridge crash issue on Android 2.3.x.(link to issue). So I still don't have a good solution now. Please help.
Thank in advance for any help.
Okay, you've got a few options! You can try to disable the keyboard completely using:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
If you choose this way, be sure to return the settings to normal if that's not done automatically. I haven't used this before and couldn't tell you how it behaves, but keep that in mind! You don't want a user to reply to a text they receive while using your app only to have their keyboard disabled :)
You could use something similar to the following link. I haven't dug through it very thoroughly (tl;dr) but he creates a custom view that extends from android.inputmethodservice.KeyboardView and uses that instead.
https://stackoverflow.com/a/1947370/1183256
Lastly (I'm not sure how much this would differentiate from the first one) you could create your own IME.
How to develop a soft keyboard for Android?
http://developer.android.com/guide/topics/text/creating-input-method.html
I'd like to have the search field on my website automatically gain focus when the user loads the page, but i don't like how that pops up the keyboard for users on smartphones/tablets. Is there any javascript property I can use to detect whether or not the user has physical keyboard connected?
I'm not sure about that...but if you check this link out, it'll show you how to detect whether a user is on a mobile platform or not. you could make your decision based on that?