Legacy keyCode lookup

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.

Capture

Current key

Waiting…

Press any key to capture keydown

event.type

keydown or keyup

event.key

Character or named key

event.code

Physical keyboard position

event.keyCode

Deprecated numeric value

event.which

Legacy numeric alias

event.location

Standard, left, right, or numpad

event.repeat

True while a key is held

Modifier keys

Shift, Ctrl, Alt, and Meta

Recent Events

Latest 8 events
TypeKeyCodeModifiersRepeat
Press a key to populate the event history.

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.

Related Keyboard Event Guides