Last modified on December 21, 2008, at 12:07

Keyboard events

This is the current revision of Keyboard events as edited by Ed Poor (Talk | contribs) at 12:07, December 21, 2008. This URL is a permanent link to this version of this page.

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

  1. JavaScript Madness: Keyboard Events