How do you design an interaction that works with both touch and a mouse?

Design for touch, mouse and keyboard from one semantic control. Use a button for an action and a link for navigation, then handle pointer events only when the component needs dragging or coordinates. The primary action should work through a normal click without input-specific branches.
Touch needs generous targets and no hover dependency. Mouse users benefit from hover feedback and precise dragging. Keyboard users need a visible focus indicator and an equivalent command. Build the shared behavior first, then layer input-specific feedback through CSS capability queries instead of maintaining separate mobile and desktop components.
Pointer Events expose mouse, pen and touch through pointerdown, pointermove and related events. Inspect pointerType only when behavior truly differs, such as pressure-sensitive drawing. Use pointer capture during a drag so the component continues receiving events when the pointer leaves its bounds.
Do not bind both touch and mouse handlers to the same action without deduplication because one gesture may generate multiple event paths. Avoid preventing default browser behavior across an entire page. Set touch-action on the interactive surface to preserve the scrolling and zooming gestures that the component does not replace.
- Tap, click and Enter or Space should trigger the same button action.
- Hover information should also appear on focus or through an explicit disclosure button.
- Drag controls should have a non-drag alternative for precise values.
- Targets should remain separated when the primary pointer is coarse.
Test with actual inputs, including a hybrid device that switches between touch and a trackpad. Verify cancellation, multi-touch, zoom, scrolling and focus restoration after dialogs. Emulation can expose basic pointer paths, but it does not reproduce finger occlusion, operating-system gestures or the timing of a real touch screen.