Below code accepts a character and prints character using keycode(String.fromCharCode). Issue arises when you enter special character like .
or ?
.
function logChar(e){
var keyCode = e.which || e.keyCode;
var char = String.fromCharCode(keyCode);
console.log(char)
}
<input type="text" onkeydown="logChar(event)" />
Can someone explain why is it returning different value and how to get same value?
Thanks in advance!