- Published on
Keyboard Events in JavaScript
- Authors
- Name
- hwahyeon
Event Type | Trigger | Features |
---|---|---|
keydown | When a key is pressed | · Responds to all keys (letters, numbers, special keys, control keys) · Repeats while key is held down · Detects special keys |
keypress | When a key is pressed | · Responds to printable characters and some control keys (e.g., Enter, Tab) · Does not detect modifier keys (e.g., Shift, Ctrl) · Deprecated and not recommended for use; use keydown instead |
keyup | When a key is released | · Responds to all keys (letters, numbers, special keys, control keys) · Detects when a key is released · Useful for verifying input or resetting state |