I will get a Char from keydown event.
In all browsers I can use event.key and it works fine, but in android the result is something else:
event.key: unidentified
event.code: ''
event.which: `229` (for [a-z0-9] is always this number)
window.event.keyCode: `229`
Here is an old stackoverflow post, but it doesn't work any more.
codepen demo for test in android (IOS and PC work fine)
How can i get key code or key string from KeyboardEvent
i was going trough the same problem in android. i found out that using the input event solved the problem. this event contains the whole string which is actualy typed so if you just one the last character typed just take the last character of the string "event.data"
document.addEventListener('input',function(event){
console.log(event)
let word = event.data === null ? '' : event.data
input.search(word)
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With