Skip to content

resolveHotkeyAlternates

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

Defined in: alternates.ts:62

Resolves the hotkeys of a hotkey object for one platform that come after the one labels show: resolveHotkeys without its first hotkey. A hotkey without alternates returns an empty array.

Call this to list the alternates next to a label, such as in a cheat sheet. Where the platform has only alternates, the first of them is the label, so it is not in this list.

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
resolveHotkeyAlternates(redo, 'windows') // ['Mod+Shift+Z']
resolveHotkeyAlternates(redo, 'mac') // []
resolveHotkeyAlternates({ default: null, alternates: ['F1', 'F2'] }, 'mac') // ['F2']