Skip to content
Normalization & format API Reference

parseHotkey

Call Signature

ts
function parseHotkey(hotkey, platform?): ParsedHotkeyChord;

Defined in: parse.ts:211

Parses a hotkey, resolving Mod for the platform. A chord, written as a string or an object, returns one parsed chord. A sequence returns one parsed chord per step. Physical tokens such as [KeyQ] keep code; they never become a logical Q.

Parameters

hotkey

AnyChord

A chord string such as 'Mod+S', a chord object, or a sequence

platform?

Platform

The target platform for resolving 'Mod' (defaults to auto-detection)

Returns

ParsedHotkeyChord

Example

ts
parseHotkey('Mod+S', 'mac') // { key: 'S', ctrl: false, shift: false, alt: false, meta: true, modifiers: ['Meta'] }
parseHotkey({ key: 'S', mod: true }, 'windows') // { key: 'S', ctrl: true, ..., modifiers: ['Control'] }
parseHotkey(['G', 'Shift+G']) // [{ key: 'G', ... }, { key: 'G', shift: true, ... }]

Call Signature

ts
function parseHotkey(hotkey, platform?): ParsedHotkeyChord[];

Defined in: parse.ts:215

Parses a hotkey, resolving Mod for the platform. A chord, written as a string or an object, returns one parsed chord. A sequence returns one parsed chord per step. Physical tokens such as [KeyQ] keep code; they never become a logical Q.

Parameters

hotkey

readonly AnyChord[]

A chord string such as 'Mod+S', a chord object, or a sequence

platform?

Platform

The target platform for resolving 'Mod' (defaults to auto-detection)

Returns

ParsedHotkeyChord[]

Example

ts
parseHotkey('Mod+S', 'mac') // { key: 'S', ctrl: false, shift: false, alt: false, meta: true, modifiers: ['Meta'] }
parseHotkey({ key: 'S', mod: true }, 'windows') // { key: 'S', ctrl: true, ..., modifiers: ['Control'] }
parseHotkey(['G', 'Shift+G']) // [{ key: 'G', ... }, { key: 'G', shift: true, ... }]

Call Signature

ts
function parseHotkey(hotkey, platform?): 
  | ParsedHotkeyChord
  | ParsedHotkeyChord[];

Defined in: parse.ts:219

Parses a hotkey, resolving Mod for the platform. A chord, written as a string or an object, returns one parsed chord. A sequence returns one parsed chord per step. Physical tokens such as [KeyQ] keep code; they never become a logical Q.

Parameters

hotkey

AnyChord | readonly AnyChord[]

A chord string such as 'Mod+S', a chord object, or a sequence

platform?

Platform

The target platform for resolving 'Mod' (defaults to auto-detection)

Returns

| ParsedHotkeyChord | ParsedHotkeyChord[]

Example

ts
parseHotkey('Mod+S', 'mac') // { key: 'S', ctrl: false, shift: false, alt: false, meta: true, modifiers: ['Meta'] }
parseHotkey({ key: 'S', mod: true }, 'windows') // { key: 'S', ctrl: true, ..., modifiers: ['Control'] }
parseHotkey(['G', 'Shift+G']) // [{ key: 'G', ... }, { key: 'G', shift: true, ... }]