https://stackoverflow.com/a/3396805
NOTE KeyPress is now deprecated. Use KeyDown instead.
KeyPress, KeyUp and KeyDown are analogous to, respectively: Click, MouseUp, and MouseDown.
Downhappens firstPresshappens second (when text is entered)Uphappens 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 );
}
566200cookie-checkonKeyPress Vs. onKeyUp and onKeyDown