Keypress:
The keypress event is sent to an element when the browser registers
keyboard input. This is similar to the keydown event, except in the
case of key repeats. If the user presses and holds a key, a keydown
event is triggered once, but separate keypress events are triggered
for each inserted character. In addition, modifier keys (such as
Shift) trigger keydown events but not keypress events.
Keydown:
The keydown event is sent to an element when the user first presses a
key on the keyboard. It can be attached to any element, but the event
is only sent to the element that has the focus. Focusable elements can
vary between browsers, but form elements can always get focus so are
reasonable candidates for this event type.
Keyup:
The keyup event is sent to an element when the user releases a key on
the keyboard. It can be attached to any element, but the event is only
sent to the element that has the focus. Focusable elements can vary
between browsers, but form elements can always get focus so are
reasonable candidates for this event type.
Also, this is a handy piece of information that is usually glossed over:
If key presses anywhere need to be caught (for example, to implement
global shortcut keys on a page), it is useful to attach this behavior
to the document object. Because of event bubbling, all key presses
will make their way up the DOM to the document object unless
explicitly stopped.
To determine which character was entered, examine the event object
that is passed to the handler function. While browsers use differing
properties to store this information, jQuery normalizes the .which
property so you can reliably use it to retrieve the character code.
Note that keydown and keyup provide a code indicating which key is
pressed, while keypress indicates which character was entered. For
example, a lowercase "a" will be reported as 65 by keydown and keyup,
but as 97 by keypress. An uppercase "A" is reported as 65 by all
events. Because of this distinction, when catching special keystrokes
such as arrow keys, .keydown() or .keyup() is a better choice.
More information regarding the cmd
key on MACs: jQuery key code for command key