TanStack
Hotkeys API Reference

useHotkey

Call Signature

ts
function useHotkey<T>(
   hotkey, 
   callback, 
   options?): void;

Defined in: useHotkey.ts:47

Registers one hotkey: a chord such as 'Mod+S', a sequence such as ['G', 'G'], or an app hotkey from defineAppHotkeys. The callback and options are refreshed after every commit.

Type Parameters

T

T extends AppHotkey<string, HotkeyChord | HotkeySequence | null>

Parameters

hotkey

T

callback

HotkeyCallback

options?

UseAppHotkeyOptions<T>

Returns

void

Call Signature

ts
function useHotkey<T>(
   hotkey, 
   callback, 
   options?): void;

Defined in: useHotkey.ts:52

Registers one hotkey: a chord such as 'Mod+S', a sequence such as ['G', 'G'], or an app hotkey from defineAppHotkeys. The callback and options are refreshed after every commit.

Type Parameters

T

T extends RegisterableHotkey

Parameters

hotkey

T

callback

HotkeyCallback

options?

AdapterOptionsFor<T, UseHotkeyTarget>

Returns

void