JavaScript KeyCodes: The Developer's Cheat Sheet
Handling keyboard input is a core part of building accessible and interactive web applications—whether you're implementing custom shortcuts, game controls, or form validation. However, the variables returned by keyboard events can be confusing. Our checker provides a live view of these properties as you type.
Important: `event.keyCode` is Deprecated
For many years, event.keyCode (returning a number like 13 for Enter) was the standard. Modern web standards have officially **deprecated** this property. While most browsers still support it for backward compatibility, you should transition your code to use the newer properties:
- event.key: Returns the actual character pressed (e.g., "Enter", "a", or "Shift"). This is the most reliable way to handle input.
- event.code: Returns the physical key on the keyboard (e.g., "KeyA", "Space"). This is useful for games where the key position matters more than the character produced.
How to use this tool
Simply click anywhere on this page and press any key on your keyboard. The interface will instantly update with the **Key**, **Code**, and **Location** properties. We also show the numeric KeyCode for those working on legacy codebases that still require it.
Modifier Keys
This tool also tracks modifier keys like **Shift, Alt, Control, and Meta (Command/Windows)**. You can see how these keys modify the event.key value in real-time. This is perfect for debugging complex keyboard combinations in your React or Angular projects.