Skip to content

KnownHotkey

ts
type KnownHotkey<T, TParam> = [
  | UnknownHotkeyKeys<T>
  | UnknownStepKeys<T>
  | UnknownEntryKeys<T>
  | UnknownAlternateKeys<T>] extends [never] ? TParam : [T] extends [infer THotkey] ? [THotkey] extends [ReadonlyArray<unknown>] ? KnownSteps<THotkey> : THotkey & { [K in UnknownHotkeyKeys<THotkey>]: never } & [UnknownEntryKeys<THotkey>] extends [never] ? unknown : KnownEntries<THotkey> & [UnknownAlternateKeys<THotkey>] extends [never] ? unknown : object : never;

Defined in: hotkey.types.ts:321

The parameter type for a function that infers its hotkey's type T. It is TParam, unless the hotkey is an object with a key that no hotkey object has, such as a misspelled platform (macos) or modifier (shfit). That key is then an error, at the top level, in a step of a sequence, in the chord object of a platform entry, and in an alternate. A type parameter alone accepts extra keys.

Type Parameters

T

T

TParam

TParam = T

Example

ts
function useHotkey<const T extends RegisterableHotkey>(
  hotkey: KnownHotkey<T, T | null | undefined>,
): void