If you’re trying to handle key presses without the usual browser weirdness, this kirupa article is a clean walkthrough of keyboard events in JavaScript.
It keeps the basics practical and easy to follow, which is honestly all I want from event docs most days.
Does the kirupa walkthrough actually compare event. key vs event. code when you switch to a non‑US layout or hit dead keys? not sure about that detail.
pretty sure it doesn’t, no. most of those walkthroughs stop at US qwerty and never touch dead keys or layout switching.
on a qwertz keyboard, event.code still says KeyZ when you press the physical z key, even though event.key may give you y. dead keys are the annoying bit too — you can get key as "Dead" before the accent actually lands.
Dead keys being event. key === "Dead" is such a “tutorial didn’t cover this mechanic” moment lol — when you mentioned the accent not landing until the next key, are you handling that by listening for compositionend/input and ignoring the initial keydown, or did you find a cleaner way? ngl I might be wrong here.
i’d ignore the keydown for Dead and wait for input or compositionend.
that’s where the actual text shows up — so you type the accent, nothing useful happens yet, then the field gets é on the next input. trying to “handle” it in keydown usually just turns into a mess.
i’ve had better luck treating keydown as shortcuts only, and letting text entry sort itself out. input has been the least annoying one for me, though i’m not pretending every IME/browser combo behaves nicely.