I am handling a keyup event and need to type a character.
This is not reliable. On keyup you will only get keyCode , not charCode .
(If you think about this, it makes sense: charCode is associated with a key-typed character that can be offset using a modifier key and thus generate another character for the base key; by keyup and keydown , since these events are not immediately associated with the dialed new character, there is no known character to generate.)
So, if you are doing something that depends on whether a character has been entered . , you will need to use the keypress event.
If you want to know when the abstract tag is discarded . / > on some common keyboard layouts, you can do this with keyup using the keyCode specified in the unixpapa link. Using keyCode , like this, is commonly used for games and other functions where the actual position of the key is important rather than the character that it generates when you type.
Unfortunately, browsers made an inconsistent mess with some key codes, including this one, so you will need to check it for all the possible values listed above, and you cannot reliably tell about the difference between the main keyboard period, the numpad period / delete key and the main delete key .
source share