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 situation
<div contenteditable="true"></div> <input> <span id="keycode"></span> script:
$('div, input').on('keydown', function (e) { $('#keycode').html(e.keyCode); }); DEMO
Fortunately I can find posts about this, but I couldn't find one with a working solution. Someone suggested to use keyup instead or to use the textInput event, but that one is only fired on blur.
Now, to top it all, this doesn't happen with the default stock browser :(
Any help would be appreciated!
UPDATE: If it turns out that this is not possible I can still grab the char before the caret: post
According to the website, key-code for . is 190. I've experienced the same, got 46 for dot .
Key codes are numeric values that correspond to physical keys on the keyboard but do not necessarily correspond to a particular character.
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.
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