3

For HTML/JS in mobile browsers, I'm having an issue where blur events trigger differently in iOS and Android. In iOS, a user can click on "Done" on the native keyboard, which hides the keyboard and causes the focused element to blur.

The same, however, does not happen when a user clicks the back icon in Android to hide the native keyboard; The elements that were previously focused keep their focus.

Is there a way to listen for the keyboard hiding and trigger a blur on the focused element? Or is there a way to force the Android keyboard to display a "done" button? Or is there a generally better solution?

1 Answers1

0

Maybe a solution would be to listen to the keydown event on the input, and check if the keypress is "Enter".

To do that, please refer to this :

Enter key press event in JavaScript

Community
  • 1
  • 1
Scalpweb
  • 1,971
  • 1
  • 12
  • 14
  • I am not looking for the user to press enter, I am looking for the keyboard hiding, which can be done without pressing enter. I do not believe the native "keyboard hide" button has a keydown/keypress/keyup event bound to it. – user2746900 Sep 10 '13 at 15:22
  • Hum yeah, sorry. I may have found a solution, but I'm not sure it's going to work for you. Check this out: http://stackoverflow.com/questions/2593139/ipad-web-app-detect-virtual-keyboard-using-javascript-in-safari – Scalpweb Sep 11 '13 at 12:20