force keyboard open on android

11,242

Android pulls up soft keyboard whenever text input field is in focus. "Go" or "Done" button on Android works as form submit, therefore input text looses focus and keyboard disappears. User expects the keyboard to disappear after "Go", "Done" or "Enter" is pressed - so Android follows this rule. Forcing re-focus on field's blur will not do much since technically you moved to a different window.

$('body').click(function() { $('#typer').focus(); }

can provide a partial solution, whereby user has to click once anywhere in the body of the page for the typer to re-gain focus. It causes OS to move back to browser Activity and focus the input field. This fiddle shows it as an example: http://jsfiddle.net/Exceeder/Z6SFH/ (use http://jsfiddle.net/Exceeder/Z6SFH/embedded/result/ on your Android device)

Other than writing a PhoneGap-like wrapper to control imeOptions of the keyboard, I am not aware of any solution that can solve this problem.

Share:
11,242
e382df99a7950919789725ceeec126
Author by

e382df99a7950919789725ceeec126

Updated on June 18, 2022

Comments

  • e382df99a7950919789725ceeec126
    e382df99a7950919789725ceeec126 about 2 years

    does anybody knows how to force keyboard open on android browser (4.0 - maybe less)? i tried this solution and it does not worked for me.

    in project i am trying to get a text input working, but after submitting (intercept by jQuery) it holds focus but the keyboard disappears.

    snippets:

    $('#typer').blur(function () {
        $(this).focus().click();
    });
    
    $('#typer').bind('keyup', function (e) {
        var input = $.trim($(this).val());
        // some lines of code..
        $(this).val('').focus(); // clean up
    }
    

    iOS is also interesting.. but not tested yet.