16

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.

Community
  • 1
  • 1
  • It is not very clear, what you are trying to achieve. This works: http://jsfiddle.net/Exceeder/Z6SFH/ (I created a fiddle to follow your problem) and keyboard does not disappear. But soft keyboard is picky about what state and style your #typer is in. Do you want the keyboard to stay on screen no matter what user touches with the finger? – Alex Pakka Mar 14 '12 at 15:26
  • 1
    the problem is that the keyboard disappears after submitting. the same as in your example. It happens after pressing "Go". Any idea? – e382df99a7950919789725ceeec126 Mar 15 '12 at 16:16
  • Ah. The "Go" button... see this: http://stackoverflow.com/questions/6545086/html-why-does-android-browser-show-go-instead-of-next-in-keyboard – Alex Pakka Mar 15 '12 at 18:50

1 Answers1

8

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.

Alex Pakka
  • 9,466
  • 3
  • 45
  • 69
  • thanks alex, i already do the workaround with the click on document. its sad that there is no good api for that. `$(document).click(function () { $('#typer').focus(); })` – e382df99a7950919789725ceeec126 Mar 15 '12 at 22:52
  • Guys, lets post new issues on the Chromium bug tracker for this. It's the only way to make it happen. I posted mine here: https://code.google.com/p/chromium/issues/detail?id=435871&thanks=435871&ts=1416704707 Just pretend you didn't see my issue and post a duplicate so they see the need for this more. – trusktr Nov 23 '14 at 01:05