Keycode Checker
Instantly get keyboard event data
(event.key, event.code, etc.) in your browser.
| key | code | keyCode |
|---|---|---|
| Key history will appear here | ||
You might also like
About Keycode Checker
Keycode Checker is a developer tool that allows you to instantly check how the keyboard keys you press in your browser are recognized as event data within JavaScript.
In frontend development, accurate key detection is required when implementing shortcut keys or game controls based on user input. With this tool, you can get key properties like event.key, event.code, and event.keyCode at a glance and copy them with a single click. It's also easy to test the behavior of different keyboard layouts (such as JIS vs US) and combinations with modifier keys like Shift and Ctrl.
You can also check your keyboard input history and safely test the suppression of browser default actions (such as Tab movement or Space scrolling) within the browser when e.preventDefault() is enabled.
How to Get and Check Keycodes
Press a key
With this page open, simply press the physical keyboard key you want to check.
Check results and test
The pressed key will be displayed large in the center, and its properties like event.key and event.code will appear below. You can also turn on "Prevent Default" to test browser behavior.
Copy the code
Click the retrieved value to instantly copy it to your clipboard for use in your source code. You can also view recent keypresses in the history list.
Keyboard Event Glossary
- event.key
- Represents the character or function actually inputted by the user. For example, pressing
Shift+1on a US keyboard yields!as theevent.key. It is the most recommended property for evaluating logical input. - event.code
- Indicates the physical position of the key pressed. Regardless of the keyboard language layout, pressing the key in the "A" position will always return
KeyA. This is highly useful for actions dependent on physical layout, like WASD movement in games. - event.keyCode / event.which
- Returns a system-specific numerical code assigned to the pressed key (e.g.,
65for A). Although long used in JavaScript development, these are now deprecated. They should only be used for backward compatibility checks. - event.location
- A number indicating the physical region of the keyboard where the key was pressed. It can distinguish between standard keys (0), left modifiers (1), right modifiers (2), and numpad keys (3).
- preventDefault()
- A JavaScript method used to cancel the browser's default behavior triggered by an event, such as scrolling down the page when the Space key is pressed.
Frequently Asked Questions (FAQ)
- Q.Can I use this on a smartphone or tablet?
- It works properly if you have a physical keyboard connected. However, with an on-screen software keyboard, the keydown event may not fire correctly depending on the OS or browser implementation, or it may always return the same keycode (e.g., 229). This tool is intended for use with physical keyboards.
- Q.Should I use event.key or event.code?
- It depends on your use case. If you want to evaluate the meaning of the key or the character inputted (e.g., 'Press Enter to submit'), use event.key. On the other hand, if you want to base actions on the physical position on the keyboard (e.g., 'Move character with W, A, S, D'), using event.code is the best practice.
- Q.Can I prevent shortcuts like F5 or Ctrl+W?
- Even if you use JavaScript's e.preventDefault(), you may not be able to completely prevent powerful shortcut keys reserved at the security or OS/browser level, such as closing tabs, reloading windows, or opening browser developer tools.
- Q.Why is event.keyCode deprecated?
- Because the numerical value returned can vary depending on the browser, OS, and keyboard layout, leading to compatibility issues. It is currently recommended to use event.key or event.code.
- Q.Is the inputted key data sent to a server?
- No, it is not sent. All processing is completed using JavaScript within your browser, and your key input history is never sent to or saved on any external server.
Common Use Cases
Here are typical development scenarios where checking keycodes is necessary.
Implementing Web App Shortcuts
When implementing shortcuts like "Ctrl + S" to save or "Escape" to close a modal, this tool helps you build accurate conditional statements combining event.key and modifiers (Ctrl, Alt, Shift, Meta).
Browser Game Controller Development
In action games, when registering event listeners for user input (like WASD movement or Space to jump), use this tool to verify and implement layout-independent event.code values.
Cross-Browser Layout Compatibility Testing
Use it to check output differences for event.key when pressing symbol keys (like @ or +) across different layouts (e.g., JIS vs US keyboards) to design bug-free input forms.
Disabling Specific Key Inputs
Helpful for testing preventDefault() to block unintended form submissions with Enter, or to restrict input fields to numbers only.
Send Feedback
Please let us know your thoughts to help us improve the tool.
Feedback is temporarily suspended
The server is busy or spam protection is active. Please try again later.