nicholas
nicholas

Reputation: 14563

auto tabbing between text fields in iOS

I'm trying to auto-tab text fields whenever a key is pressed (so only one letter goes in each input).

I've attached the following to the keyup event on the inputs:

var next = $(e.target).next();
while(next.length && !next.is('input')) next = next.next();
next.focus();

In a browser this looks for the next input (or the end of the form) and moves to focus to it. Works perfectly.

On an iOS device, though, it looks like it's working in the sense that the next input gets all focus styling, but the keyboard goes away and you have to touch an input to get it back.

How do I get around this?

edit: in response to the negative feedback to auto-tabbing. Let me rephrase the question:

I'm building a very simple, iPad specific, trivia game for a client. Answer the question, hit next, answer the question, hit next, type of thing. We have a number of question formats: multiple choice, scrabble style rearrange the letters, and... a "Wheel of Fortune"-ish fill in the word question.

I'm doing this by having n inputs representing the letters in the word, and having to tab (hit next on an iPad) each letter is a pain.

How might I go about build this question format for iPad?

Upvotes: 1

Views: 3516

Answers (1)

DA.
DA.

Reputation: 40671

You can't force-trigger a keyboard in iOS using JavaScript. While you easily set focus on a field, the keyboard will only appear upon a user-initiated interaction (tap).

(I also agree with the comments that in most cases, auto-tabbing is a bad idea from a UX perspective to begin with.)

EDIT: in regards to the wheel of fortune aspect, you could simply build your own keyboard. The bonus would be that you could gray out the letters already chosen.

Upvotes: 2

Related Questions