JavaScript Keyboard Events Cheatsheet
JavaScript Keyboard Events Cheatsheet
KEYBOADDDEVENTS
KEYBOA EVENTS
EVENTS
CHEATSH
CHEATSHEET
CHEATSH EET
EET
1. Keydown Event
The keydown event triggers when any key is pressed. It's useful
for detecting both character and non-character keys, such as
arrow keys or function keys.
2. KeyUp Event
The keyup event triggers when a key is released after
being pressed. It helps in capturing the key that was
released.
3. Keypress (Deprecated)
The keypress event fires when a key that produces a character
is pressed. This event is deprecated and replaced by keydown
for broader compatibility. keys.
Key Differences
Keydown: Captures any key, including non-
character keys (e.g., Shift, Ctrl, etc.)
Keyup: Useful for detecting key release.
Keypress: Only captures keys that produce a
character value (e.g., letters, numbers,
punctuation). It is deprecated in favor of
keydown and keyup.
Common Properties of
the event Object
event.shiftKey,event.ctrlKey,event.altKey,
@eldnight