JavaScript KeyCode List & Key Event Reference

Press any key to see its event.key, event.code, keyCode, and which values. Searchable list of every standard keyboard event code.

About This Tool

Press any key and instantly see every JavaScript keyboard event property — event.key, event.code, the legacy keyCode and which values, all four modifier states (ctrlKey, shiftKey, altKey, metaKey), and the physical key location (standard, left, right, or numpad). The interactive area at the top captures the native KeyboardEvent directly, so what you see is exactly what your own addEventListener("keydown", …) handler would receive.

Handling keyboard input correctly is one of the most common challenges in front-end development. The legacy keyCode and which properties were once the only reliable way to identify keys, but they behave inconsistently across browsers and keyboard layouts. The modern event.key property returns a human-readable string like "Enter" or "ArrowUp", while event.code identifies the physical key regardless of which character it produces. This tool shows all three representations side by side so you can pick the right one for your use case.

The searchable reference table below lists every standard key with its name, event.key value, event.code value, and legacy keyCode number. You can filter by category (letters, numbers, function keys, navigation, modifiers, punctuation, or special keys) and use the search bar to jump to any key instantly. When you press a key in the interactive area, the matching row in the table is highlighted for quick cross-reference. If you are looking for application-specific shortcuts, see the Keyboard Shortcut Reference for VS Code, Chrome DevTools, and more. For character code lookups, the ASCII & Unicode Table covers code points, hex values, and HTML entities.

All processing happens entirely in your browser. No keystrokes are recorded, transmitted, or stored on any server. This makes the tool safe to use in any environment, including when testing keyboard shortcuts that involve sensitive modifier combinations. If you need to validate a string of key sequences against a pattern — for example, parsing user-defined hotkeys from a config file — pair this tool with the Regex Tester to build and verify the matching expression.

How to Use

  1. Click the Press Any Key area at the top to give it keyboard focus.
  2. Press any key on your keyboard. The tool instantly displays event.key, event.code, keyCode, which, modifier states, and the key location.
  3. Click the copy button next to any value to copy it to your clipboard.
  4. Scroll down to the Reference Table to browse all available key codes.
  5. Use the search bar to filter by key name, event value, keyCode number, or description.
  6. Switch category tabs (Letters, Numbers, Function, Navigation, Modifiers, Punctuation, Special) to narrow the table.
  7. The table row matching your last pressed key is automatically highlighted for easy identification.

FAQ

What is event.key in JavaScript?

event.key is a property on the KeyboardEvent object that returns a string describing the key that was pressed, taking into account the active keyboard layout, IME, and modifier keys. For printable characters, it returns the actual character produced — "a", "A", "!", or " " for the space bar. For non-printable keys, it returns a descriptive name from the UI Events spec — "Enter", "Escape", "ArrowUp", "Tab", "F5", and so on. event.key is the recommended modern replacement for the deprecated event.keyCode and event.which because it is consistent across browsers, layouts, and locales. Use it for shortcuts and text input; use event.code instead when you need to identify the physical key position regardless of layout (for example, WASD game controls).

What is the difference between event.key and event.code?

event.key returns the character or function associated with the key press, taking into account modifiers and keyboard layout (e.g., pressing Shift+1 gives "!"). event.code identifies the physical key on the keyboard regardless of layout or modifiers (e.g., "Digit1" is always the same physical key, whether you type "1" or "!").

Is event.keyCode deprecated?

Yes. Both event.keyCode and event.which are deprecated in the UI Events specification. They remain supported in browsers for backward compatibility and are still widely searched by developers. For new code, use event.key or event.code instead.

Why do some keys not trigger an event?

Certain keys and key combinations are intercepted by the operating system or browser before they reach the page. For example, Cmd+Q on macOS quits the browser, and Ctrl+W closes the tab. Print Screen may also be captured by the OS. These events cannot be reliably detected in web applications.

What does the location property mean?

event.location indicates where on the keyboard a key is located. The value 0 (Standard) means a general key, 1 (Left) and 2 (Right) distinguish between duplicate keys like left and right Shift, and 3 (Numpad) identifies number pad keys.

Is my data safe?

Absolutely. This tool captures keyboard events using the browser's native KeyboardEvent API and reads event.key, event.code, and event.keyCode properties -- all in-memory, client-side operations. No keystrokes are recorded, sent to a server, or stored anywhere. You can verify this by checking the Network tab in your browser's DevTools.

Should I use keydown, keyup, or keypress?

Use keydown for most use cases, as it fires for all keys including modifiers and function keys. The keypress event is deprecated and no longer fires in modern browsers for non-printable keys. Use keyup only when you specifically need to know when a key is released.

Why are keyCode values different on different keyboards?

The legacy keyCode values can vary between keyboard layouts and operating systems, which is one reason they were deprecated. For example, the semicolon key may report different codes on US vs. European layouts. This inconsistency is why the W3C recommends using event.key (for the character produced) or event.code (for the physical key) in modern applications.

Related Tools