When a user types a letter on the keyboard,
this usually triggers the keyboard events*
keyup (in this order).
Some of these properties are the same across browsers (e.g.
Other properties may be platform-dependent (e.g.
event.which is available in Firefox, Opera, Safari, Chrome,
but not in Internet Explorer).
Arguably, the most useful properties are
event.charCode, because these properties allow your script to answer the questions:
Demo: Press or release any key on your keyboard, and the text boxes below will display the actual keyboard event properties available in your browser ():
*In addition to
keyup, recent versions of Safari and Google Chrome support the
however, it is still too early to use
textInput in a cross-browser fashion.
Note also that some properties are event-specific
(e.g., in Safari and Chrome
is available for
textInput events, but not for