On 5/21/07, james_027 <[EMAIL PROTECTED]> wrote:


Hi,

Is there a difference between to two? Any guidelines on which one to
use on a certion situation?


There are three javascript events that can fire when a key is pressed:

keydown
keyup
keypress

Here's a great reference for figuring out what happens on each one depending
on what key you're looking at/for:

http://www.quirksmode.org/js/keys.html

Generally keydown is needed to capture special keys (Ctrl, Alt, Caps,
Arrows) that don't fire keypress, and sometimes to prevent the normal
behavior of a keypress/combination (by returning false or stopping
propagation). Ex: prevent enter from adding a newline in a textarea or
editable div.

- Richard D. Worth

Reply via email to