Back to DocsRecipe
Keyboard Form Navigation
Ship a form where power users never touch the mouse. Tab, Enter, Escape, and arrow keys drive every interaction — save, cancel, and field traversal all work from the keyboard.
Ingredients
onKeyDowncapture phase on the form elemente.keyswitch on Enter, Escape, Tab, ArrowUp, ArrowDowne.preventDefault()suppress default browser behavior where neededuseReffocus ring management for field-to-field jumps
Pattern
- 1Wrap all inputs in a single
<form>with anonKeyDownhandler. - 2Enter submits. Escape fires a cancel callback. Tab moves forward; Shift+Tab moves backward.
- 3Arrow keys inside select lists or radio groups cycle options without opening a dropdown.
- 4Ctrl+S triggers save. Announce the shortcut via a subtle
aria-labelon the form.