Ryan
Ryan

Reputation: 2817

Show iPad keyboard on select, focus or always (jQuery)

I have a web app that is using jQuery to replace the RETURN key with TAB so that when I user presses return the form is not submitted but rather the cursor moves to the next text field.

This works in all browsers but only 1/2 works on the iPad. On the iPad the next field is highlighted but the keyboard is hidden. How can I keep the keyboard visible or force it somehow?

Here's my code (thanks to http://thinksimply.com/blog/jquery-enter-tab):

function checkForEnter (event) {
    if (event.keyCode == 13) {
          currentBoxNumber = textboxes.index(this);
        if (textboxes[currentBoxNumber + 1] != null) {
            nextBox = textboxes[currentBoxNumber + 1]
            nextBox.focus();
            nextBox.select();
            event.preventDefault();
            return false;
        }
    }
}

Drupal.behaviors.formFields = function(context) {   
    $('input[type="text"]').focus(function() { $(this).removeClass("idleField").addClass("focusField"); });
    $('input[type="text"]').blur(function() { $(this).removeClass("focusField").addClass("idleField"); });

    // replaces the enter/return key function with tab
    textboxes = $("input.form-text");
    if ($.browser.mozilla) {
       $(textboxes).keypress (checkForEnter);
    } else {
       $(textboxes).keydown (checkForEnter);
    }
};

Upvotes: 3

Views: 3645

Answers (1)

Glauco Vinicius
Glauco Vinicius

Reputation: 2647

I believe it's not possible to show the keyboard without the user touching a text input element and triggering click, mouseup or mousedown.

This appears to be by design:

By design, some focus() events in Mobile Safari are ignored. A lot of sites would do focus() unnecessarily and bringing up the keyboard is slow/intrusive.

Upvotes: 2

Related Questions