The keydown and keyup fire for each keypress (for example, for the shift key). They report the key (the "key" has no lower or upper case). keypress reports one event for combined strokes (e.g. SHIFT plus A) and ASCII code (with the correct upper / lower case representation).
The solution is to listen for the keypress event. If you support older browsers, you should go with this code (according to this site ):
String.fromCharCode(evt.charCode || evt.keyCode);
More on this stack question .
source share