NOTE KeyPress
is now deprecated. Use KeyDown
instead.
KeyPress
, KeyUp
and KeyDown
are analogous to, respectively: Click
, MouseUp,
and MouseDown
.
Down
happens firstPress
happens second (when text is entered)Up
happens last (when text input is complete).
The exception is webkit, which has an extra event in there:
keydown
keypress
textInput
keyup
Below is a snippet you can use to see for yourself when the events get fired:
window.addEventListener("keyup", log);
window.addEventListener("keypress", log);
window.addEventListener("keydown", log);
function log(event){
console.log( event.type );
}