5

I'm developing an web application that contains a form with two input elements. One of the user requirements is that after inserting a character into the first input it should automatically trigger the focus of the next element and show the keyboard.

After googling about it seems that isn't possible to programatically trigger the keyboard on iOS through JavaScript. The reason however isn't quite clear to me, some say that is an UX feature but I can't find any official information about it.

So my question is, where can I find some official specs that explain the technical reasons whereby this isn't possible?

Diogo Cardoso
  • 21,637
  • 26
  • 100
  • 138
  • as long as the element being focused allows input, the keyboard should show. It might slide away and come back, but it should be there. Are you sure the element with focus is an input? – MrOBrian Aug 14 '12 at 00:15
  • @MrOBrian yes, it's an input. It's possible to trigger the element focus, the problem is that it doesn't show the keyboard. – Diogo Cardoso Aug 14 '12 at 00:21
  • What version of iOS are you using for testing? In doing some searches I've been reading that people have reported it as a bug, others have said it's intentional, but there was also mention that it was fixed in iOS5. Basically, setting focus on page load, or changing focus from one text element to another, would not bring up the keyboard, but setting focus from the click event of a button would. – MrOBrian Aug 14 '12 at 16:17

1 Answers1

0

Official specs:

http://developer.apple.com/library/IOs/#documentation/AppleApplications/Reference/SafariWebContent/Introduction/Introduction.html#//apple_ref/doc/uid/TP40002079-SW1

Unfortunately, the official specs will not answer your question.

Generally, with forms on iOS safari, the keyboard will stay open until the user chooses to close it. When you auto-focus the next form input, does it close the keyboard?

Matthew Blancarte
  • 8,251
  • 2
  • 25
  • 34
  • 1
    Yes, when it auto-focus the next form input it closes the keyboard. – Diogo Cardoso Aug 14 '12 at 00:22
  • Can you paste your js that shifts the focus to the next form? – Matthew Blancarte Aug 14 '12 at 00:27
  • You can't use .focus() in iOS to focus an input, based on everything I've read and my experience with it. I was excited to see your solution for focusing a field... :) – Matthew Blancarte Aug 14 '12 at 01:05
  • It's a couple years old, but [this question](http://stackoverflow.com/questions/979309/how-do-i-focus-an-html-text-field-on-an-iphone-causing-the-keyboard-to-come-up) has an answer to it that mentions you can only focus on click, so set a button's click event to do the focus, then fire off click on the button. – MrOBrian Aug 14 '12 at 16:11