Skip to content
Normalization & format API Reference

formatHotkey

Call Signature

ts
function formatHotkey(parsed): string;

Defined in: format.ts:36

Converts a parsed hotkey back to a string, with each platform modifier spelled out, such as Control+Shift+S. A parsed chord returns a string, and a parsed sequence returns one string per step. To get Mod back where the platform allows it, use normalizeHotkey instead.

Parameters

parsed

ParsedHotkeyChord

A parsed chord, or the parsed steps of a sequence

Returns

string

Example

ts
formatHotkey(parseHotkey('Mod+Shift+S', 'windows')) // 'Control+Shift+S'
formatHotkey(parseHotkey(['G', 'Mod+K'], 'mac')) // ['G', 'Meta+K']

Call Signature

ts
function formatHotkey(parsed): string[];

Defined in: format.ts:37

Converts a parsed hotkey back to a string, with each platform modifier spelled out, such as Control+Shift+S. A parsed chord returns a string, and a parsed sequence returns one string per step. To get Mod back where the platform allows it, use normalizeHotkey instead.

Parameters

parsed

readonly ParsedHotkeyChord[]

A parsed chord, or the parsed steps of a sequence

Returns

string[]

Example

ts
formatHotkey(parseHotkey('Mod+Shift+S', 'windows')) // 'Control+Shift+S'
formatHotkey(parseHotkey(['G', 'Mod+K'], 'mac')) // ['G', 'Meta+K']

Call Signature

ts
function formatHotkey(parsed): string | string[];

Defined in: format.ts:40

Converts a parsed hotkey back to a string, with each platform modifier spelled out, such as Control+Shift+S. A parsed chord returns a string, and a parsed sequence returns one string per step. To get Mod back where the platform allows it, use normalizeHotkey instead.

Parameters

parsed

| ParsedHotkeyChord | readonly ParsedHotkeyChord[]

A parsed chord, or the parsed steps of a sequence

Returns

string | string[]

Example

ts
formatHotkey(parseHotkey('Mod+Shift+S', 'windows')) // 'Control+Shift+S'
formatHotkey(parseHotkey(['G', 'Mod+K'], 'mac')) // ['G', 'Meta+K']