Andorid Keyboard

  • 1
  • Question
  • Updated 9 years ago
How can I make the android keyboard appear when a user touches inside of a textbox? I am using phonegap build.
Photo of kp.kody

kp.kody

  • 12 Posts
  • 0 Reply Likes

Posted 9 years ago

  • 1
Photo of kp.kody

kp.kody

  • 12 Posts
  • 0 Reply Likes
No one has any suggestions? :(
Photo of Andrew Lunny

Andrew Lunny

  • 1911 Posts
  • 199 Reply Likes
This should be the default behaviour for interacting with an input tag. What is the markup you're using?

(please escape the markup, so that it will be readable on get satisfaction)
Photo of kp.kody

kp.kody

  • 12 Posts
  • 0 Reply Likes

<input type="text" onKeyDown="getResults(this.value)">
Photo of Andrew Lunny

Andrew Lunny

  • 1911 Posts
  • 199 Reply Likes
What happens if you remove the onKeyDown handler?
Photo of kp.kody

kp.kody

  • 12 Posts
  • 0 Reply Likes
I have removed the onKeyDown and still nothing.


<input type="text">
Photo of Andrew Lunny

Andrew Lunny

  • 1911 Posts
  • 199 Reply Likes
There must be something else in the code of the page - can you try uploading an empty HTML page, only containing the input box (no script tags, no styles)?

Which device and OS version are you testing on?
Photo of Kimmo Puputti

Kimmo Puputti

  • 25 Posts
  • 0 Reply Likes
Is there a way to programmatically open the keypad?

I have a search view, and I want the search input field to have focus with the keyboard open when the user goes to the view, but setting the focus with Javascript only shows the cursor on the input and a touch on the field is required to open the keypad.
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes
Hello,

There is an article here for that issue however it requires a plugin, which at the moment PhoneGap Build does not support.

http://wiki.phonegap.com/w/page/27915...

Hardeep Shoker
Photo of Tyler Charlesworth

Tyler Charlesworth

  • 4 Posts
  • 0 Reply Likes
Hardeep-
Regarding Kimmo Puputti's question: It seems like PhoneGap should show the soft keyboard automatically on a text field focus, no?
Photo of Andrew Lunny

Andrew Lunny

  • 1911 Posts
  • 199 Reply Likes
Yes, PhoneGap does this by default. Hardeep's link is only relevant if you want to display or hide the keyboard programmatically, for other purposes.

There is probably an issue with Kimmo's specific setup - either the device he's using, the OS, or some combination thereof.
Photo of Tyler Charlesworth

Tyler Charlesworth

  • 4 Posts
  • 0 Reply Likes
Andrew- Thanks for the response.
You're correct that if a user taps a text field to focus it, PhoneGap automatically shows the keyboard.
The issue that is being seen is that if the text field is focused via JavaScript ( dom_node.focus() ), the keyboard is not automatically shown.
Photo of thyagoponzoni

thyagoponzoni

  • 1 Post
  • 0 Reply Likes
I've just tested this and it does not seem to be the right info. See below:

function focusInputText() {
document.getElementById("txt").focus();
}
<input id="txt" type="text">

PhoneGap does show the keyboard regardless.
Can you please inform how you came to that conclusion?
Thanks.
Photo of Tyler Charlesworth

Tyler Charlesworth

  • 4 Posts
  • 0 Reply Likes
thyagoponzoni- Thanks for investigating. I've tried the following super basic index.html file and the keyboard consistently fails to show (on Android 2.2):

<!DOCTYPE HTML>
<html>

<head>
<script type="text/javascript" src="lib/phonegap/phonegap.js"></script>
<script type="text/javascript">
window.onload = function() {
document.getElementById("txt").focus();
};
</script>
</head>

<body>
<input id="txt" type="text" placeholder="PLACEHOLDER">
</body>

</html>


The PLACEHOLDER text disappears, indicating the field has focus, but the keyboard does not appear.
Photo of Andrew Lunny

Andrew Lunny

  • 1911 Posts
  • 199 Reply Likes
Does this work as expected in the Android browser, outside of PhoneGap?
Photo of Tyler Charlesworth

Tyler Charlesworth

  • 4 Posts
  • 0 Reply Likes
Behaves the same (erroneous) way for me in the Android browser: http://tylercharlesworth.com/public/2...
Photo of Andrew Lunny

Andrew Lunny

  • 1911 Posts
  • 199 Reply Likes
This is probably an Android issue then, not one that PhoneGap has any direct control over.

I didn't see an existing issue here:
http://code.google.com/p/android/issu...
so you may want to file a new one.