keyCode on android is always 229

后端 未结 7 1443
长情又很酷
长情又很酷 2020-11-28 08:23

On my Samsung Galaxy tab 4 (Android 4.4.2, Chrome: 49.0.2623.105) I ran into a situation where the keyCode is always 229.

I\'ve setup a simple test for two situatio

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 09:03

    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.

提交回复
热议问题