JavaScript Key Code Finder

Find the JavaScript event key, code, and which value for any key you press.

Discover JavaScript key codes, event codes, and key values by pressing any key on your keyboard. This free interactive tool captures keyboard events in real time and displays the keyCode, event.key, event.code, and which properties used in JavaScript event handling. Essential for developers building keyboard shortcuts, game controls, accessibility features, and custom input handlers. All processing happens locally in your browser with zero external dependencies.

-
event.key
Press any key
event.code
-

Press any key on your keyboard to see its value.

Your data stays in your browser
Was this tool useful?
Tutorial

How to use

1
1

Usage Step

Find the JavaScript event key, code, and which value for any key you press.

Guide

Complete Guide to JavaScript Key Codes

What Are JavaScript Key Codes?

JavaScript key codes are numeric values assigned to each key on a keyboard. When a user presses a key, the browser fires keyboard events (keydown, keyup, keypress) that contain properties like keyCode, key, code, and which. The keyCode property returns an integer (e.g., 13 for Enter, 27 for Escape), while event.key returns a string representation of the key ('Enter', 'Escape'). The event.code property represents the physical key on the keyboard regardless of layout, making it valuable for games and international keyboard support.

Why Key Code Lookup Matters for Developers

Building keyboard-driven interfaces requires knowing the exact codes for target keys. Whether you are implementing keyboard shortcuts (Ctrl+S to save), game controls (WASD movement), accessible navigation (Tab, Enter, Escape), or custom hotkeys, you need reliable key code references. Different browsers historically returned different keyCode values for some keys, making an interactive lookup tool essential for cross-browser testing and verification.

Key vs Code vs KeyCode Properties

The event.key property returns the logical meaning of the key (e.g., 'a' or 'A' depending on Shift state). The event.code property returns the physical key identifier (e.g., 'KeyA' regardless of keyboard layout or Shift state). The legacy event.keyCode returns a numeric integer that varies by key. Modern web development favors event.key and event.code over the deprecated keyCode, but legacy codebases still rely heavily on numeric key codes.

Best Practices for Keyboard Event Handling

Use event.key for character input detection and event.code for physical key position (important for games). Always handle both keydown and keyup for key combinations. Prevent default behavior carefully — blocking keyboard events can break accessibility. Test with different keyboard layouts (QWERTY, AZERTY, Dvorak) to ensure your key handling works internationally. Use this tool to verify key codes across browsers before hardcoding values into your application.

Examples

Worked Examples

Example: Building a Keyboard Shortcut Handler

Given: You need to implement Ctrl+S (save) and Escape (close modal) keyboard shortcuts.

1

Step 1: Press Ctrl on this tool to find: keyCode=17, key='Control', code='ControlLeft'.

2

Step 2: Press S to find: keyCode=83, key='s', code='KeyS'.

3

Step 3: Press Escape to find: keyCode=27, key='Escape', code='Escape'.

4

Step 4: Use these values in your event listener: if (e.ctrlKey && e.key === 's') handleSave();

Result: You now have the exact key identifiers needed to implement both shortcuts in your JavaScript code.

Example: Game Movement Controls

Given: You need WASD keys for character movement in a browser game.

1

Step 1: Press W to find: code='KeyW' — use this for the forward movement binding.

2

Step 2: Press A, S, D to find their respective event.code values (KeyA, KeyS, KeyD).

3

Step 3: Use event.code instead of event.key so controls work regardless of keyboard layout.

Result: Physical key codes that work correctly on QWERTY, AZERTY, and other keyboard layouts worldwide.

Use Cases

Use cases

Keyboard Shortcut Development

Quickly look up key codes when building keyboard shortcuts for web applications. Whether implementing Ctrl+Z for undo, Ctrl+Shift+P for command palettes, or custom hotkeys for productivity tools, this tool gives you the exact keyCode, event.key, and event.code values you need. Simply press the key combination and copy the values directly into your JavaScript event handler code.

Game Control Mapping

Identify key codes for browser-based game controls including WASD movement, space for jump, shift for sprint, and number keys for inventory slots. Using event.code ensures your controls work correctly across different keyboard layouts worldwide, which is critical for games with an international player base. This tool helps you verify physical key positions independent of language settings.

Accessibility Testing and Development

Verify key codes for accessibility-critical keys like Tab, Enter, Escape, Arrow keys, and Space that are essential for keyboard navigation in web applications. WCAG compliance requires all interactive elements to be keyboard accessible. This tool helps developers confirm the correct key values for focus management, modal dialogs, dropdown menus, and custom widget interactions.

Frequently Asked Questions

?How do I find a JavaScript key code?

Simply press any key on your keyboard while this tool is active. It instantly displays the keyCode, event.key, event.code, and which values for the pressed key.

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

keyCode returns a numeric integer (e.g., 13 for Enter), while event.key returns a descriptive string ('Enter'). Modern JavaScript prefers event.key as keyCode is deprecated, but both are widely used in existing codebases.

?What is event.code used for?

event.code identifies the physical key on the keyboard regardless of the current keyboard layout or language. For example, the key in the Q position always returns 'KeyQ' whether the layout is QWERTY or AZERTY.

?Is keyCode deprecated in JavaScript?

Yes, the keyCode property is technically deprecated by the W3C specification in favor of event.key and event.code. However, it remains widely supported by all browsers and is still used in many production codebases.

?Does this tool work with all keyboard layouts?

Yes, this tool captures keyboard events directly from your browser, so it works with any keyboard layout including QWERTY, AZERTY, Dvorak, and international layouts.

?Is this key code tool free and private?

Yes, completely free with no registration. All key detection happens locally in your browser — no keystrokes are recorded or transmitted to any server.

?What key code is Enter?

The Enter key has keyCode 13, event.key 'Enter', and event.code 'Enter'. The numeric keypad Enter has the same keyCode but event.code 'NumpadEnter'.

?How do I detect arrow keys in JavaScript?

Arrow keys have keyCode values 37 (Left), 38 (Up), 39 (Right), and 40 (Down). Using event.key, they return 'ArrowLeft', 'ArrowUp', 'ArrowRight', and 'ArrowDown' respectively.

Help us improve

How do you like this tool?

Every tool on Kitmul is built from real user requests. Your rating and suggestions help us fix bugs, add missing features and build the tools you actually need.

Rate this tool

Tap a star to tell us how useful this tool was for you.

Suggest an improvement or report a bug

Missing a feature? Found a bug? Have an idea? Tell us and we'll look into it.

Related Tools

Recommended Reading

Recommended Books on JavaScript & Web Development

As an Amazon Associate we earn from qualifying purchases.

Boost Your Capabilities

Professional Products to Boost Your Development Setup

As an Amazon Associate we earn from qualifying purchases.

Newsletter

Get Free Productivity Tips & New Tools First

Join makers and developers who care about privacy. Every issue: new tool drops, productivity hacks, and insider updates — no spam, ever.

Priority access to new tools
Unsubscribe anytime, no questions asked