Keyboard events

Keyboard events occur when the user types on a computer keyboard. The computer can detect which key has been pressed, as well as the exact moment it goes down and is released. Many computer keyboards also have a "typematic" feature: if a key is held down long enough, it starts repeating automatically. This is handy for deleting a dozen or more characters at a time, or entering the same character repeatedly (as when drawing a line of x's across the page).

The main keyboard events (in JavaScript) are:[1]

* keydown - user strikes key
* keypress - character is generated
* keyup - user releases key

Note that keys like Home and End keys do not generate characters. The key codes they generate tell a word processing program to move the cursor.

## Notes[edit]

1. ↑ JavaScript Madness: Keyboard Events