Focus() function not working for iOS device

5,996 views
Skip to first unread message

anurag kasheup

unread,
May 25, 2012, 7:49:14 AM5/25/12
to phon...@googlegroups.com

This is an HTML / CSS / JS (jQuery) iPad app. I've got a button, that slides down an input form. I'd like to focus the user on the input, and then launch the keyboard.

This is what I'm working with, but doesn't work:

$('#myFormField').focus();

This does indeed focus the input, but fails to launch the keyboard. Is it just not possible (for security reasons or whatever)?

Is there a way to force or simulate a user tapping the input (or anything for that matter)?

Thanks!

Kerri Shotts

unread,
May 25, 2012, 11:29:21 AM5/25/12
to phon...@googlegroups.com
From what I've read, the only way to do this is to have the focus() event be triggered from a click event -- then the keyboard launches. Unfortunately the code I saw used an HTML button to focus and launch the keyboard -- which wasn't my goal of launching the keyboard without user intervention. Unfortunately, all my attempts at trying to "simulate" the click event failed to launch the keyboard, and for now, it seems that it is a known issue. Whether or not Apple will resolve this or not is questionable -- I can understand the reasons why the keyboard doesn't appear on just any focus() command, but it seems nuts that there's no obvious way to force the issue.

Now, a plugin might work, for this, but I'm not immediately certain on how that would work -- if the webview indicated it was capable of becoming the firstResponder and a plugin call told it to become firstResponder, that might do the trick? Alternatively, the webview might be using some other method to handling input, and that might not work at all... but it's a thought...

bri...@differenz.co.in

unread,
Jan 24, 2014, 5:14:44 AM1/24/14
to phon...@googlegroups.com, anurag...@gmail.com
I am facing same issue, have you got any solutions ?

jcesarmobile

unread,
Jan 24, 2014, 5:45:05 AM1/24/14
to phon...@googlegroups.com, anurag...@gmail.com
On iOS 6 and greater, it should work if you change this preference on the config.xml
<preference name="KeyboardDisplayRequiresUserAction" value="false" />
Reply all
Reply to author
Forward
0 new messages