Press any key on your keyboard to see all its event properties including key, code, keyCode, which, and modifier states. An essential tool for developers working with keyboard events in JavaScript.
Press any key to start...
Key events are captured from the entire window
Simply press any key on your keyboard while the tool is focused. The display instantly shows all keyboard event properties for the pressed key: event.key (the character or key name like 'a', 'Enter', 'ArrowUp'), event.code (the physical key identifier like 'KeyA', 'Enter', 'ArrowUp'), event.keyCode (the legacy numeric code like 65 for 'A', 13 for Enter), event.which (legacy, same as keyCode for keydown), event.charCode (for keypress events), and event.location (0=standard, 1=left, 2=right, 3=numpad). Modifier key states (Ctrl, Shift, Alt, Meta/Windows/Command) are shown with visual indicators. A history of recent key presses is maintained so you can compare different keys. A ready-to-use JavaScript code snippet is provided for each key.
Keycode information is essential for JavaScript developers implementing keyboard shortcuts, hotkeys, and key bindings in web applications, game developers mapping keyboard controls, accessibility engineers ensuring keyboard navigation works correctly, developers building custom text editors or terminal emulators that need precise key handling, anyone migrating from the deprecated keyCode/which properties to the modern key/code API, developers debugging keyboard event issues across different browsers and operating systems, and building keyboard-driven interfaces like command palettes (Cmd+K), modal dialogs (Escape to close), or spreadsheet-like navigation (arrow keys, Tab, Enter).
JavaScript keyboard events fire in this order: keydown → keypress (deprecated) → keyup. The modern API uses event.key (logical key value) and event.code (physical key location). event.key returns 'a' or 'A' depending on Shift state, while event.code always returns 'KeyA' regardless of modifiers or keyboard layout. The deprecated event.keyCode returns numeric values (65-90 for A-Z, 48-57 for 0-9, 112-123 for F1-F12, 13 for Enter, 27 for Escape, 32 for Space, 37-40 for arrow keys). event.location distinguishes between left/right variants of Shift, Ctrl, Alt, and Meta keys, and identifies numpad keys. The code property is layout-independent - 'KeyA' always refers to the physical key in the 'A' position on a QWERTY layout, even on AZERTY or Dvorak keyboards.
event.key returns the logical value of the key pressed - 'a' for lowercase a, 'A' with Shift, 'Enter' for the enter key. event.code returns the physical key's position on the keyboard - always 'KeyA' for the A-position key regardless of whether Shift is held or what keyboard layout is used. Use 'key' for text input handling, 'code' for keyboard shortcuts.
Yes, event.keyCode and event.which are deprecated in favor of event.key and event.code. However, keyCode is still widely supported and commonly used. The modern key/code API is recommended for new code because it's more intuitive, supports international keyboards better, and distinguishes between left/right modifier keys.
Listen for 'keydown' events and check both the key/code and modifier properties: if (e.ctrlKey && e.key === 's') { e.preventDefault(); save(); }. For cross-platform shortcuts, check e.metaKey on macOS (Cmd) and e.ctrlKey on Windows/Linux (Ctrl). Use event.code for layout-independent shortcuts.
Transform, format, generate, and encode data instantly. Private, fast, and always free.
Browse All Tools