| Category | Event types |
|---|---|
| Keyboard | keydown, keyup (keypress deprecated) |
| Mouse | click, contextmenu, mouseenter, wheel |
| Pointer, touch | pointerdown ... (Touch Events, Pointer Events) |
| Text entry | beforeinput, input, change, compositionend |
document.addEventListener("keydown", (e) => {
if (e.key !== "s" || !(e.ctrlKey || e.metaKey) || e.isComposing) return;
e.preventDefault(); // suppress the browser's Save Page dialog
saveDraft();
});key is the character produced (layout-aware); code is the physical key ("KeyS"), better for games. isComposing is true while a Chinese or Japanese input method is composing.