KeyCode Tester
Check legacy keyCode values while also seeing the modern event.key and event.code values you should prefer in new JavaScript.
Quick Answer
A keyCode tester shows the deprecated numeric keyCode for a pressed key, plus modern KeyboardEvent values so you can update or debug legacy JavaScript safely.
Live KeyCode Tester
Press a key to see its keyCode value and compare it with event.key, event.code, which, location, repeat, and modifier states.
Current key press
Waiting...
Press any key to start
event.key
-
Value produced by the key
event.code
-
Physical keyboard position
event.keyCode
-
Legacy numeric value
event.which
-
Legacy alias
event.location
-
Left, right, or numpad hint
event.repeat
-
True when held down
Modifier Keys
Waiting
Shift, Ctrl, Alt, Meta
Common Uses
- Maintain older JavaScript that still checks keyCode.
- Translate legacy keyCode comparisons to event.key or event.code.
- Debug browser behavior when migrating keyboard handlers.
- Confirm exact numeric values before changing old code.
Event Values to Watch
event.keyCode
The deprecated numeric value historically used to identify keyboard keys.
event.which
Another legacy numeric value that often mirrors keyCode for keyboard events.
event.key
The modern value to use when you care about the character or named key.
event.code
The modern value to use when you care about the physical key position.
Frequently Asked Questions
Is event.keyCode deprecated?
Yes. event.keyCode is deprecated. Use event.key for the value produced by the key or event.code for the physical key location.
Why does this tester still show keyCode?
Many older apps, snippets, and libraries still contain keyCode checks. Showing keyCode next to modern values makes migration and debugging easier.
Should I use event.key or event.code instead?
Use event.key when the produced character matters. Use event.code when the physical key position matters, such as game controls or layout-independent shortcuts.