Press Any Key
Focus this window and press a key on your keyboard to reveal its JavaScript event data.
Understanding JavaScript Key Events
event.key vs event.code
event.key returns the character value (e.g., "a" or "A"). Use this for text input.
event.code returns the physical key position (e.g., "KeyA"). Use this for games or shortcuts where layout shouldn't matter (WASD works on AZERTY too).
Deprecated Properties
event.which and event.keyCode are deprecated. They are inconsistent across browsers. You should always prefer key or code for modern web development.
Advertisement