Open mobile keyboard automatically

3

Currently I have the following block attached to the user action.

$(".class-botao").focus()

When the user interacts with the page the mobile keyboard is displayed normally.

But in my application there is a method that checks if there is any empty input when loading the page and if there is I give .focus() in the element;

autoFocus: function(scope) {
    var firstInput = $('.class-input.empty:required').filter(':first:visible');

    if (!firstInput.length) {
        return false;
    }

    firstInput.focus();
    return true;
},

Everything works normally but the keyboard does not appear (IOS / Android),

I have tried to simulate events .trigger('click // touchstart') shortly after focus() , but nothing on the keyboard appears: /

Does anyone have any tips?

    
asked by anonymous 13.09.2016 / 23:30

1 answer

2

Mobile keyboard virtual can only be enabled by user actions , by usability settings.

In this way, the correct method to invoke the keyboard of mobile devices is through the type of input element, for example:

<input type="text" /> will automatically invoke the default alphanumeric keyboard when receiving focus, while <input type="number" /> will invoke the numeric keypad

There are two exceptions for javascript:

  • Some say the prompt() global method works
  • Trigger the focus event within events raised by user action, for example: click , mousedown , or mouseup
16.11.2016 / 00:11