ReferenceBehavior
Hotkey
Register a keyboard shortcut that invokes a player action
Import
Anatomy
Behavior
Hotkey is a behavior component: it renders no visible interface. Place it inside a Container to register one key pattern and player action.
By default, the shortcut responds while the player container has focus. Set target="document" only when the shortcut should apply across the entire document.
Key patterns are case-insensitive and may use:
- Named keys such as
Space,ArrowLeft, andArrowRight. - Exact modifiers such as
Ctrl+k,Shift+f,Alt+m, andMeta+k. ModforMetaon macOS andCtrlelsewhere.- The special
0-9range for digit-based seeking.
Choose an action from the API reference below. Pass value as seconds for seekStep, a volume delta such as 0.05 or -0.05 for volumeStep, or a percentage from 0 to 100 for seekToPercent. When omitted, seekStep defaults to 10 seconds and volumeStep defaults to five percentage points; ArrowLeft, j, and ArrowDown use the negative step. When value is omitted from seekToPercent with keys="0-9", the pressed digit supplies the percentage.
Toggle actions ignore held-key repeats. Step, rate, and percentage actions may repeat. A matched shortcut prevents the browser’s default behavior. Unmodified shortcuts are ignored in editable fields, and Space or Enter still activates focused buttons, links, and sliders normally.
Accessibility
Hotkeys supplement operable controls; they should never be the only way to perform an action. Built-in buttons use matching hotkey registrations to expose aria-keyshortcuts, and their tooltips can display the registered shortcut.
Examples
Basic Usage
This player uses Space to play or pause, M to mute, and the arrow keys to seek by five seconds. Click the player first to focus its container.
Space: play/pause · M: mute · ←/→: seek