Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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);
    }
};
like image 252
Ryan Avatar asked Dec 05 '25 19:12

Ryan


1 Answers

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.

like image 108
Glauco Vinicius Avatar answered Dec 08 '25 10:12

Glauco Vinicius



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!