Keycode Info
Find key code, code, keyCode, location, and modifier information for any keyboard press instantly in your browser.
What is a Keycode Info Tool?
A Keycode Info Tool is an interactive utility that displays detailed information about any key you press on your keyboard. It captures keyboard events in real time and shows the JavaScript event properties including the key name, keyCode, code, location, and active modifier keys (Ctrl, Shift, Alt, Meta). This tool is essential for web developers, game developers, and anyone building keyboard-driven interfaces who needs to understand how keyboard events work across different browsers and operating systems.
Understanding Keyboard Events
When you press a key on your keyboard, the browser fires a keydown event containing several properties that describe the key press. The Keycode Info tool captures these properties and displays them in a clear, readable format:
- Key: The character value of the key pressed (e.g.,
a,Enter,Shift). For printable keys, this returns the actual character; for special keys, it returns the key name. - KeyCode: A numeric code representing the key that was pressed. Note that this property is deprecated but still widely used for legacy compatibility.
- Code: A string that identifies the physical key on the keyboard (e.g.,
KeyA,Enter,ShiftLeft). This value remains the same regardless of keyboard layout or modifier state. - Location: A number indicating the location of the key on the keyboard —
0for standard keys,1for left-side modifiers,2for right-side modifiers,3for Numpad keys. - Modifiers: Shows which modifier keys (Meta, Shift, Ctrl, Alt) are currently held down during the key press.
Common Use Cases
- Web Development: Debug keyboard event handlers and understand which properties to use for keyboard shortcuts, navigation, and form interactions
- Game Development: Map game controls to specific keyboard keys and handle simultaneous key presses with modifier combinations
- Accessibility: Test keyboard navigation and ensure your application responds correctly to all keyboard inputs
- Cross-Browser Testing: Verify that keyboard events behave consistently across different browsers and operating systems
- Keyboard Shortcuts: Design and test custom keyboard shortcuts with modifier key combinations
How to Use This Keycode Info Tool
- Press a key: Simply press any key on your keyboard. The tool automatically captures the key press and displays its information.
- View details: Read the displayed values for key, keyCode, code, location, and modifiers.
- Test combinations: Hold down modifier keys (Ctrl, Shift, Alt, Meta) while pressing other keys to see how modifier combinations are reported.
- Compare keys: Press different keys to compare their properties and understand the differences between similar keys (e.g., left Shift vs right Shift).
For more developer tools, check out our JSON Formatter, JavaScript Minifier, and HTML Formatter.
Frequently Asked Questions
What is the difference between key and code?
The key property returns the character value of the key pressed, which changes based on keyboard layout and modifier state (e.g., pressing Shift+a gives "A"). The code property returns the physical key location on the keyboard (e.g., "KeyA") and remains the same regardless of modifiers or keyboard layout.
Is the keyCode property deprecated?
Yes, the keyCode property is deprecated by the W3C and should not be used in new code. Modern browsers recommend using the key property for character input and the code property for physical key identification. However, this tool still displays keyCode for compatibility with legacy code.
Why do some keys show different codes on different keyboards?
The code property represents the physical key position, which is consistent across keyboards with the same layout (e.g., QWERTY). However, different keyboard layouts (AZERTY, QWERTZ, etc.) have different physical arrangements, so the same letter may have a different code. The key property reflects the actual character produced, which adapts to the user's active keyboard layout.
What does the location value mean?
The location value indicates where on the keyboard the key is physically located: 0 for standard keys, 1 for left-side modifier keys, 2 for right-side modifier keys, and 3 for keys on the numeric keypad. This is useful for distinguishing between duplicate keys like left and right Shift.
Can I test multi-key combinations with this tool?
Yes. Hold down one or more modifier keys (Ctrl, Shift, Alt, or Meta) and then press another key. The tool will display all active modifiers in the Modifiers field along with the primary key's properties. This is helpful for testing keyboard shortcuts and complex key combinations.