Events like keyup
and keydown
will return 65 for both a
and A
(and also true
for event.shiftKey
if that key is held down).
The keypress
event returns different keycodes for upper and lower case letters, so to get this working case sensitive you should use the keypress
event, and fromCharCode()
will return the correct letter, case sensitive.