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 … Read more

How to detect escape key press with pure JS or jQuery?

Note: keyCode is becoming deprecated, use key instead. function keyPress (e) { if(e.key === “Escape”) { // write your logic here. } } Code Snippet: var msg = document.getElementById(‘state-msg’); document.body.addEventListener(‘keypress’, function(e) { if (e.key == “Escape”) { msg.textContent += ‘Escape pressed:’ } }); Press ESC key <span id=”state-msg”></span> keyCode is becoming deprecated It seems keydown … Read more