Reading the values
event.code describes the physical key position (KeyA, Digit1), while event.key is the character it produced. keyCode is deprecated but still used by older code.
Frequently asked questions
Layout dependent?
event.key changes with layout; event.code stays physical.
Mobile keyboards?
Virtual keyboards may report keyCode 0.
Repeat keydown?
Hold a key and the last values stay shown.