Skip to content

formatHotkey

formatHotkey(hotkey, separator): string

Defined in: extensions/commands/format.ts:53

Utility that formats a hotkey to display in a user interface. Modifier keys use symbols on Mac and labels otherwise.

string

Hotkey to format for display.

string = ...

String to join the segments together with. Defaults to " " on Mac and "+" otherwise.

string

Formatted key for display.

// On Mac
formatHotkey("mod+s") // "⌘ S"
formatHotkey("12+escape") // "⇧ ⌘ Esc"
formatHotkey("arrowup") // "↑"
// On Windows/Linux
formatHotkey("mod+s") // "Ctrl+S"
formatHotkey("12+escape") // "Shift+Win+Esc"
formatHotkey("arrowup") // "↑"