keyCode on android is always 229 keyCode on android is always 229 android android

keyCode on android is always 229


Normal keypress event does not give keyCode in android device. There has already been a big discussion on this.

If you want to capture the press of space bar or special chars, you can use textInput event.

$('input').on('textInput', e => {     var keyCode = e.originalEvent.data.charCodeAt(0);     // keyCode is ASCII of character entered.})

Note: textInput does not get triggered on alphabets, number, backspace, enter and few other keys.


I had the same issue and could not find any solutions.

event.target.value.charAt(event.target.selectionStart - 1).charCodeAt()


Running into the same problem, only happens with stock Samsung keyboard on Android. A work around was to turn off the keyboard predictions, which fixed the input. Still analysing further to see if a work around can be found in JS land.

Edit: I've managed to find a solution for our case. What was happening, is that we had a whitelist of allowed characters that a user was allowed to enter in our input box. These were alphanumeric characters plus some whitelisted control characters (e.g. enter, esc, up/down). Any other character input would have the event default prevented.

What happened is that all events with keycode 229 were being prevented, and as a result no text was entered. Once we added keycode 229 to the whitelist as well, everything went back to functioning ok.

So if you are using some kind of custom or 3rd party form input control component, make sure to check that keycode 229 is whitelisted/allowed and not default prevented.

Hope this helps someone.