Find which key code a key actually fires

event.key and event.code are not the same thing, and neither is stable across layouts. See exactly what your browser reports for each key.

Tools used in this guide

The job

You are wiring a keyboard shortcut and need to know what the browser sees: is that key code KeyP regardless of layout, and does the middle Enter differ from the numpad one? Press the key and read the values directly.

key versus code versus location

event.key is the produced character — it changes with layout and Shift (“a” vs “A”). event.code is the physical position — KeyA stays KeyA on AZERTY where it types Q. event.location distinguishes left from right modifiers and numpad digits.

The modifier notation line combines what was held: “Control+Shift+K” is what a shortcut listener would compare against.

What can differ

IME-composed input, OS-level shortcuts, and some media keys never reach the page. Dead keys on international layouts fire events with key “Dead”. Values can differ between browsers — test in the browser your users actually run.