How to convert keycode to character using javascript
var key_code = 65;   result should be
character = "a"; 
                key 13 keycode is for ENTER key.
e.keyCode - used to get the number that represents the key on the keyboard. e.charCode - a number that represents the unicode character of the key on keyboard.
Tests of onkeydown reveal that when the "normal" enter key is pressed, keyCode=13 and location=0; when the numpad enter is pressed, keyCode=13 and location=3.
String.fromCharCode() is what you want:
The fromCharCode() method converts Unicode values to characters.
Syntax
String.fromCharCode(n1, n2, ..., nX)
As seen here:
String.fromCharCode((96 <= key && key <= 105) ? key-48 : key) 
                        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