Skip to content

resolveHotkeys

ts
function resolveHotkeys<T>(hotkey, platform?): PlatformHotkeyEntries<NonNullable<T>>[];

Defined in: alternates.ts:31

Resolves every hotkey of a hotkey for one platform, in order: its entry for the platform, then its alternates. The first one is the hotkey that labels show. An alternate without a hotkey on the platform is left out, and so is one equal to an earlier hotkey. A chord or a sequence returns itself, and no hotkey returns an empty array.

Registration and formatting resolve hotkey objects themselves. Call this to read the hotkeys yourself, such as to check each one for conflicts.

Type Parameters

T

T

Parameters

hotkey

T

A hotkey object, or any other hotkey

platform?

HotkeyPlatform = ...

The target platform. Defaults to auto-detection.

Returns

PlatformHotkeyEntries<NonNullable<T>>[]

Example

ts
const redo = {
  default: 'Mod+Y',
  mac: 'Mod+Shift+Z',
  alternates: [{ default: 'Mod+Shift+Z', mac: null }],
} as const
resolveHotkeys(redo, 'windows') // ['Mod+Y', 'Mod+Shift+Z']
resolveHotkeys(redo, 'mac') // ['Mod+Shift+Z']
resolveHotkeys({ default: null, alternates: ['F1', 'F2'] }, 'mac') // ['F1', 'F2']