function createFormatForDisplay(): {
(hotkey, options): string[][];
(hotkey, options): string[];
(hotkey, options?): string;
(hotkey, options): string | string[] | string[][];
};Defined in: createFormatForDisplay.ts:29
Returns formatForDisplay with the provider's platform as the default, so labels match the user's platform. Call in a component; the returned function works anywhere, and JSX updates when the provider's platform changes. An explicit platform option wins.
Physical bindings such as [KeyQ] are labeled with the character the key types for this user in Chromium browsers, once the keyboard layout has loaded, and JSX updates when the layout arrives. See createKeyboardLayout. An explicit layoutMap option wins. Firefox and Safari report no layout, so labels there keep the key's US character.
Server-rendered apps should set the provider's defaultOptions.platform from the request user agent with detectPlatform(userAgent).
(hotkey, options): string[][];Formats a hotkey for display in a user interface.
In a server-rendered app, format labels with your adapter's formatter, such as useFormatForDisplay, or pass platform. Called directly, formatForDisplay never reads a provider's platform. Without a platform option, it renders Linux labels on the server, so Mac users get a different label after hydration.
On macOS, uses symbols (⇧⌘S) in Control, Option, Shift, Command order. Display ordering does not change the normalized hotkey used for registration. On Windows/Linux, uses text (Ctrl+Shift+S) with + separators. The separator can be customized with separatorToken. Physical codes use conventional display labels: [KeyS] becomes S and [Digit2] becomes 2. Keys with no US key use their keycap legends: [IntlBackslash] and [IntlRo] become \ and [IntlYen] becomes ¥. These labels do not infer the active keyboard layout or change matching. Supply a resolved layoutMap for layout-aware labels; keyLabels overrides both layout entries and fallback labels. Sequence steps are formatted individually and joined with sequenceSeparator (a space by default).
A key reported by a KeyboardEvent, such as a held key from KeyStateTracker, can be outside the key types: pass it as { key }.
readonly DisplayHotkeyChord[]
A logical or physical hotkey string, raw object, ParsedHotkeyChord, or sequence
FormatDisplayOptions & object
Formatting options
string[][]
Display text, or individual key labels when parts is true (one array per step for sequences)
formatForDisplay('Mod+Shift+S', { platform: 'mac' })
// Returns: '⇧ ⌘ S' (symbols separated by spaces on macOS)
formatForDisplay('Mod+Shift+S', { platform: 'windows' })
// Returns: 'Ctrl+Shift+S'
formatForDisplay('Escape')
// Returns: 'Esc' (on all platforms)
formatForDisplay('Shift', { platform: 'mac' })
// Returns: '⇧'
formatForDisplay({ key: heldKey })
// A key from a KeyboardEvent, such as a held key
formatForDisplay(['G', 'H'])
// Returns: 'G H'(hotkey, options): string[];Formats a hotkey for display in a user interface.
In a server-rendered app, format labels with your adapter's formatter, such as useFormatForDisplay, or pass platform. Called directly, formatForDisplay never reads a provider's platform. Without a platform option, it renders Linux labels on the server, so Mac users get a different label after hydration.
On macOS, uses symbols (⇧⌘S) in Control, Option, Shift, Command order. Display ordering does not change the normalized hotkey used for registration. On Windows/Linux, uses text (Ctrl+Shift+S) with + separators. The separator can be customized with separatorToken. Physical codes use conventional display labels: [KeyS] becomes S and [Digit2] becomes 2. Keys with no US key use their keycap legends: [IntlBackslash] and [IntlRo] become \ and [IntlYen] becomes ¥. These labels do not infer the active keyboard layout or change matching. Supply a resolved layoutMap for layout-aware labels; keyLabels overrides both layout entries and fallback labels. Sequence steps are formatted individually and joined with sequenceSeparator (a space by default).
A key reported by a KeyboardEvent, such as a held key from KeyStateTracker, can be outside the key types: pass it as { key }.
DisplayHotkeyChord
A logical or physical hotkey string, raw object, ParsedHotkeyChord, or sequence
FormatDisplayOptions & object
Formatting options
string[]
Display text, or individual key labels when parts is true (one array per step for sequences)
formatForDisplay('Mod+Shift+S', { platform: 'mac' })
// Returns: '⇧ ⌘ S' (symbols separated by spaces on macOS)
formatForDisplay('Mod+Shift+S', { platform: 'windows' })
// Returns: 'Ctrl+Shift+S'
formatForDisplay('Escape')
// Returns: 'Esc' (on all platforms)
formatForDisplay('Shift', { platform: 'mac' })
// Returns: '⇧'
formatForDisplay({ key: heldKey })
// A key from a KeyboardEvent, such as a held key
formatForDisplay(['G', 'H'])
// Returns: 'G H'(hotkey, options?): string;Formats a hotkey for display in a user interface.
In a server-rendered app, format labels with your adapter's formatter, such as useFormatForDisplay, or pass platform. Called directly, formatForDisplay never reads a provider's platform. Without a platform option, it renders Linux labels on the server, so Mac users get a different label after hydration.
On macOS, uses symbols (⇧⌘S) in Control, Option, Shift, Command order. Display ordering does not change the normalized hotkey used for registration. On Windows/Linux, uses text (Ctrl+Shift+S) with + separators. The separator can be customized with separatorToken. Physical codes use conventional display labels: [KeyS] becomes S and [Digit2] becomes 2. Keys with no US key use their keycap legends: [IntlBackslash] and [IntlRo] become \ and [IntlYen] becomes ¥. These labels do not infer the active keyboard layout or change matching. Supply a resolved layoutMap for layout-aware labels; keyLabels overrides both layout entries and fallback labels. Sequence steps are formatted individually and joined with sequenceSeparator (a space by default).
A key reported by a KeyboardEvent, such as a held key from KeyStateTracker, can be outside the key types: pass it as { key }.
DisplayHotkey
A logical or physical hotkey string, raw object, ParsedHotkeyChord, or sequence
FormatDisplayOptions & object
Formatting options
string
Display text, or individual key labels when parts is true (one array per step for sequences)
formatForDisplay('Mod+Shift+S', { platform: 'mac' })
// Returns: '⇧ ⌘ S' (symbols separated by spaces on macOS)
formatForDisplay('Mod+Shift+S', { platform: 'windows' })
// Returns: 'Ctrl+Shift+S'
formatForDisplay('Escape')
// Returns: 'Esc' (on all platforms)
formatForDisplay('Shift', { platform: 'mac' })
// Returns: '⇧'
formatForDisplay({ key: heldKey })
// A key from a KeyboardEvent, such as a held key
formatForDisplay(['G', 'H'])
// Returns: 'G H'(hotkey, options): string | string[] | string[][];Formats a hotkey for display in a user interface.
In a server-rendered app, format labels with your adapter's formatter, such as useFormatForDisplay, or pass platform. Called directly, formatForDisplay never reads a provider's platform. Without a platform option, it renders Linux labels on the server, so Mac users get a different label after hydration.
On macOS, uses symbols (⇧⌘S) in Control, Option, Shift, Command order. Display ordering does not change the normalized hotkey used for registration. On Windows/Linux, uses text (Ctrl+Shift+S) with + separators. The separator can be customized with separatorToken. Physical codes use conventional display labels: [KeyS] becomes S and [Digit2] becomes 2. Keys with no US key use their keycap legends: [IntlBackslash] and [IntlRo] become \ and [IntlYen] becomes ¥. These labels do not infer the active keyboard layout or change matching. Supply a resolved layoutMap for layout-aware labels; keyLabels overrides both layout entries and fallback labels. Sequence steps are formatted individually and joined with sequenceSeparator (a space by default).
A key reported by a KeyboardEvent, such as a held key from KeyStateTracker, can be outside the key types: pass it as { key }.
DisplayHotkey
A logical or physical hotkey string, raw object, ParsedHotkeyChord, or sequence
FormatDisplayOptions
Formatting options
string | string[] | string[][]
Display text, or individual key labels when parts is true (one array per step for sequences)
formatForDisplay('Mod+Shift+S', { platform: 'mac' })
// Returns: '⇧ ⌘ S' (symbols separated by spaces on macOS)
formatForDisplay('Mod+Shift+S', { platform: 'windows' })
// Returns: 'Ctrl+Shift+S'
formatForDisplay('Escape')
// Returns: 'Esc' (on all platforms)
formatForDisplay('Shift', { platform: 'mac' })
// Returns: '⇧'
formatForDisplay({ key: heldKey })
// A key from a KeyboardEvent, such as a held key
formatForDisplay(['G', 'H'])
// Returns: 'G H'function SaveButton() {
const formatForDisplay = createFormatForDisplay()
return <kbd>{formatForDisplay('Mod+S')}</kbd>
}