Choose the event that matches what you want to know, not the device.
Pointing: pointer events. pointerdown, pointermove, pointerup and pointercancel fire for mouse, touch and pen alike; pointerType says which, and pointerId separates simultaneous touches. Two tools matter for drags:
el.setPointerCapture(event.pointerId)sends that pointer's later events toeleven after the pointer leaves it, untilpointerup.- CSS
touch-actiontells the browser which panning or zooming it may start itself. Withouttouch-action: noneon a touch drag, the browser may take the gesture to pan or zoom, and firespointercancelwhen it does.
Mouse events still fire after pointer events for compatibility; canceling pointerdown suppresses the later mousedown/mouseup, but not click. Touch events are needed only for code that predates pointer events.
Activation: click. It fires for mouse, touch, and Enter or Space on a focused button, so it's the right event for "the user activated this".
Keys: keydown. event.key is the value produced, after layout and modifiers ("a", "A", "!", "Enter"). event.code is the physical key ("KeyA", "Digit1"), the same on every layout. Use key for shortcuts named by character and code for position-based controls such as WASD. keypress is deprecated.
Text: input and beforeinput. Text arrives by typing, paste, drag, autocorrect, dictation and IMEs, so key events can't track it. beforeinput fires before the edit with inputType and data, and canceling it blocks the edit. input fires after and can't be canceled.
Composition. IMEs build text in steps between compositionstart and compositionend. Those steps fire beforeinput/input with isComposing: true, and that beforeinput can't be canceled. Validate or search on compositionend, not on every step.