Reputation: 6188
This script is supposed to catch key presses. But it is getting special characters wrongly received. For example, pressing \
results in Ü
.
document.addEventListener('keydown', keydownCallback, false);
function keydownCallback(e) {
var charCode = (typeof e.which == "number") ? e.which : e.keyCode;
if (charCode) {
console.log("Character typed: " + String.fromCharCode(charCode));
}
}
Is there any way in which I can get the input characters correct?
Upvotes: 1
Views: 62
Reputation: 1202
You could use KeyBoardEvent.key
e.g. in your case e.key
would be "\"
when the backslash is pressed.
Upvotes: 1