Skip to content

resolvePlatformHotkey

ts
function resolvePlatformHotkey<T>(hotkey, platform?): 
  | PlatformHotkeyEntry<NonNullable<T>>
  | null;

Defined in: platform.ts:104

Resolves a hotkey per platform to the hotkey for one platform: its entry for the platform, or its default. Returns null when the platform has no hotkey. A chord, a sequence, or a chord object is returned as is, and no hotkey (null or undefined) returns null.

Registration and formatting resolve these objects themselves. Call this to read the hotkey yourself, such as an app hotkey's in a settings screen.

Type Parameters

T

T

Parameters

hotkey

T

A hotkey per platform, or any other hotkey

platform?

HotkeyPlatform

The target platform. Defaults to auto-detection.

Returns

| PlatformHotkeyEntry<NonNullable<T>> | null

Example

ts
resolvePlatformHotkey({ default: 'Mod+Y', mac: 'Mod+Shift+Z' }, 'mac') // 'Mod+Shift+Z'
resolvePlatformHotkey({ default: null, mac: 'Mod+,' }, 'windows') // null
resolvePlatformHotkey('Mod+S', 'mac') // 'Mod+S'