I'm trying to capture user input (for custom non-html input field) so I need unicode hex key of input character
Others answers suggest something like this:
function detectkey(event) {
var unicode = event.which || event.keyCode;
document.getElementById("keystroke").innerHTML = "The pressed key was: " + String.fromCharCode(unicode) +"<br>The Unicode value is:"+ unicode;
}
But both event.which and event.keyCode and also charCode are deprecated
Proofs:
As you can see here https://keycode.info/ There are 2 ways left - event.key and event.code
Damn seems like I need to use keypress event instead. It don't gives you control presses
UPD: Damn*2, it's also deprecated
https://developer.mozilla.org/en-US/docs/Web/API/Document/keypress_event