Skip to main content
Version: 4.3

KeyboardEventHandlers

type KeyboardEventHandlers = Record<string, (event) => void>;

Maps keyboard shortcut strings to the callbacks they trigger, as accepted by useOnKeyboardEvents.

A shortcut can be a single key ('enter', 'esc', 'delete') or a combo joined with + ('ctrl+c', 'ctrl+alt+t', 'command+s'). Bind one handler to several shortcuts by separating them with spaces ('up down left right'). Shortcuts match keydown by default; prefix with an event type to listen on keyup or keypress instead ('keyup:ctrl+x', 'keypress:a'). Each callback receives the native keyboard event, so you can call event.preventDefault() or read event.key.