The numbers returned from the key code card are in the next set, as defined here . This set is not ASCII compliant, but is similar in some respects. I will look, see if I can find additional information on how to get characters from numbers.
I also recommend using e.which instead of e.keyCode
And as another comment, w3schools never trusts.
Take a look at e.originalEvent.keyIdentifier , it seems to contain some unicode. But it still displays numpad in AH instead of 0-9. I think he just hates numpad. There must be a bnlean isnumpad flag somewhere. The DOM3 API has a logical numeric keypad.
Turns e.originalEvent.keyLocation === 3 when you press 1 on the numeric keypad.
From specification W3
KeyboardEvent.DOM_KEY_LOCATION_STANDARD The value of the KeyboardEvent.DOM_KEY_LOCATION_STANDARD constant is 0x00. KeyboardEvent.DOM_KEY_LOCATION_LEFT The value of the KeyboardEvent.DOM_KEY_LOCATION_LEFT constant is 0x01. KeyboardEvent.DOM_KEY_LOCATION_RIGHT The value of the KeyboardEvent.DOM_KEY_LOCATION_RIGHT constant is 0x02. KeyboardEvent.DOM_KEY_LOCATION_NUMPAD The value of the KeyboardEvent.DOM_KEY_LOCATION_NUMPAD constant is 0x03
So, the keyword === 3 maps to DOM_KEY_LOCATION_NUMPAD. Then you will need to catch numpad manually. you can subtract 48 from the code key for numpad to map AH to 0-9
[Big disclaimer]
This is what FF and Chrome do. God knows what IE is doing, you can defeat this beast yourself. I have no doubt that he is doing something completely different from the W3 spec.
source share