Hotkeys API Reference
- HotkeyManager
- getHotkeyManager
- HotkeyScopesState
- Hotkey
- HotkeyChord
- HotkeySequence
- RegisterableHotkey
- RegisterableHotkeyChord
- RegisterableHotkeySequence
- RawHotkeyChord
- HotkeyOptions
- HotkeyChordOptions
- HotkeySequenceOptions
- HotkeyOptionsFor
- HotkeyRegistrationHandle
- HotkeyRegistrationView
- HotkeyChordRegistrationView
- HotkeySequenceRegistrationView
- HotkeyRegistrationStatus
- toHotkeyRegistrationView
- HotkeyCallback
- HotkeyCallbackContext
- HotkeyChordCallbackContext
- HotkeySequenceCallbackContext
- HotkeyCallbackContextFor
- HotkeyMeta
- ConflictBehavior
- isHotkeySequence
- simplifyHotkey
- createSequenceMatcher
- DEFAULT_SEQUENCE_TIMEOUT
- AppHotkeysProvider
- HotkeysProvider
- useDefaultHotkeysOptions
- useFormatForDisplay
- useHotkey
- useHotkeyRegistrations
- useHotkeyScopesState
- useHotkeys
- useHotkeysContext
- AppHotkeysProviderProps
- HotkeysProviderOptions
- HotkeysProviderProps
- UseHotkeyChordOptions
- UseHotkeyCommonOptions
- UseHotkeyDefinition
- UseHotkeyOptions
- UseHotkeyOptionsFor
- UseHotkeySequenceOptions
- UseHotkeyTarget
App Hotkeys API Reference
- defineAppHotkeys
- AppHotkeysStore
- installAppHotkeysStore
- provideAppHotkeys
- publishAppHotkeysStore
- AppHotkey
- AppHotkeyInput
- AppHotkeyOptions
- AppHotkeyListItem
- AppHotkeyStatus
- AppHotkeysState
- AppHotkeysStoreOptions
- CustomHotkeys
- Register
- AppHotkeyId
- RegisteredAppHotkeys
- isAppHotkey
- isCustomHotkey
- resolveAppHotkey
- useAppHotkeyList
- useAppHotkeys
- useCustomHotkeys
- UseCustomHotkeysResult
- UseAppHotkeyOptions
Key hold & held keys API Reference
Hotkey Recorder API Reference
- HotkeyRecorder
- HotkeyRecorderOptions
- HotkeyChordRecorderOptions
- HotkeySequenceRecorderOptions
- HotkeyRecorderState
- HotkeyRecorderCommitKeys
- HotkeyRecorderValidationContext
- HotkeyChordRecorderValidationContext
- HotkeySequenceRecorderValidationContext
- RecorderOptions
- RecorderRejection
- RecorderKeyMode
- findHotkeyConflicts
- HotkeyConflict
- HotkeyConflictOptions
- useHotkeyRecorder
- ReactHotkeyRecorder
Normalization & format API Reference
- formatForDisplay
- FormatDisplayOptions
- DisplayHotkey
- DisplayHotkeyChord
- detectPlatform
- HotkeyPlatform
- formatHotkey
- normalizeHotkey
- parseHotkey
- parseKeyboardEvent
- ParsedHotkeyChord
- matchesKeyboardEvent
- areHotkeysEqual
- validateHotkey
- checkHotkey
- assertValidHotkey
- ValidationResult
- ValidatableHotkey
- LogicalKey
- PhysicalKey
- PhysicalKeyCode
- KEY_DISPLAY_SYMBOLS
- PUNCTUATION_KEY_DISPLAY_LABELS
- MAC_MODIFIER_SYMBOLS
- MAC_MODIFIER_LABELS
- WINDOWS_MODIFIER_LABELS
- LINUX_MODIFIER_LABELS
- MODIFIER_ALIASES
- MODIFIER_ORDER
- MODIFIER_KEYS
formatForAria
function formatForAria(hotkey, options?): string | undefined;Defined in: format.ts:383
Formats a hotkey for an aria-keyshortcuts attribute so screen readers can announce the shortcut. Mod+K becomes Meta+K on macOS and Control+K elsewhere.
Modifiers use the ARIA names (Control, Alt, Shift, Meta) and come before the key. Keys use KeyboardEvent.key values, such as K, /, Escape, or ArrowUp, with Space for the space bar and Plus for the plus key. A physical binding names the key at that position, so [KeyQ] becomes Q, or the key from layoutMap such as A on a French AZERTY keyboard. Logical punctuation stays as written, so '?' stays ? even where it takes Shift to type.
Returns undefined when the hotkey has no ARIA form, so the attribute is omitted. This applies to empty or null hotkeys, multi-step sequences, standalone modifiers, and physical codes with no key value such as [NumpadMemoryAdd]. A one-step sequence formats like its chord.
For a control with two shortcuts, join both formatted values with a space. In a server-rendered app, use your adapter's formatter or pass platform. Without a platform option, formatForAria uses 'linux' on the server, like formatForDisplay.
Parameters#
hotkey#
DisplayHotkey | null | undefined
A hotkey string, raw object, parsed chord, or nothing
options?#
FormatAriaOptions = {}
The platform and keyboard layout
Returns#
string | undefined
The attribute value, or undefined when there is none
Example#
formatForAria('Mod+K', { platform: 'mac' }) // 'Meta+K'
formatForAria('Mod+Shift+P', { platform: 'windows' }) // 'Control+Shift+P'
formatForAria('Shift+Space') // 'Shift+Space'
formatForAria(['G', 'H']) // undefined