All cheat sheets

Reference

Key codes cheat sheet

KeyboardEvent.key and KeyboardEvent.code values for common keys, plus the modifier checks needed for cross-platform keyboard shortcuts.

Common

Modifiers

Patterns

Things worth remembering

  • event.key is the character produced, event.code is the physical key. Use code for layout-independent shortcuts.
  • keyCode is deprecated but still appears in old snippets. Migrate to key or code.
  • Check metaKey || ctrlKey so a shortcut works on macOS and Windows alike.

More Reference sheets