Press any key to see all keyboard event properties. Essential reference for handling keyboard events.
Press any key
Click here first if keys aren't detected
Keyboard events in JavaScript provide several properties to identify which key was pressed. Understanding these properties is essential for building keyboard shortcuts, game controls, and accessible interfaces.
Use event.key for new code. keyCode is deprecated and varies across browsers and keyboard layouts. event.key gives human-readable values like "Enter", "Escape", "a", making code more maintainable.
keydown fires when a key is pressed (including modifiers and non-character keys). keypress is deprecated. keyup fires when a key is released. Use keydown for most keyboard handling.