I have written a piece of javascript code to get the key pressed within a text area. I have used the onkeydown event to capture the key pressed and am calling a function whe
keydown
and keyup
don't (mostly) give you characters at all, they give you keycodes. keypress
is where you get characters (and if you need to know, also the state of the modifier keys as of when that character was typed, on the event object's ctrlKey
, altKey
, shiftKey
, and metaKey
properties). This page goes into the madness that is keyboard events in JavaScript in loving detail...