Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

force keyboard open on android

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.

like image 390
e382df99a7950919789725ceeec126 Avatar asked Mar 14 '12 13:03

e382df99a7950919789725ceeec126


1 Answers

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.

like image 133
Alex Pakka Avatar answered Sep 20 '22 23:09

Alex Pakka