Skip to main content

HotkeyRegistrationHandle

还没翻译译自英文(tanstack.com)本页 27 段都还没译

Defined in: hotkey-manager.ts:144

A handle returned from HotkeyManager.register() that allows updating the callback and options without re-registering the hotkey.

Example

const handle = manager.register('Mod+S', callback, options)

// Update callback without re-registering (avoids stale closures)
handle.callback = newCallback

// Update options without re-registering
handle.setOptions({ enabled: false })

// Check if still active
if (handle.isActive) {
  // ...
}

// Unregister when done
handle.unregister()

Properties

callback

callback: HotkeyCallback;

Defined in: hotkey-manager.ts:149

The callback function. Can be set directly to update without re-registering. This avoids stale closures when the callback references React state.


id

readonly id: string;

Defined in: hotkey-manager.ts:151

Unique identifier for this registration


isActive

readonly isActive: boolean;

Defined in: hotkey-manager.ts:153

Check if this registration is still active (not unregistered)


setOptions

setOptions: (options) => void;

Defined in: hotkey-manager.ts:158

Update options (merged with existing options). Useful for updating enabled, preventDefault, etc. without re-registering.

Parameters

options

Partial<HotkeyOptions>

Returns

void


unregister

unregister: () => void;

Defined in: hotkey-manager.ts:160

Unregister this hotkey

Returns

void