# useHotkey

<!-- DO NOT EDIT: this page is autogenerated from the type comments -->

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

Defined in: [useHotkey.ts:93](https://github.com/TanStack/hotkeys/blob/main/packages/vue-hotkeys/src/useHotkey.ts#L93)

Vue composable for registering a hotkey: a chord such as `'Mod+S'`, a
sequence such as `['G', 'G']`, or an app hotkey from `defineAppHotkeys`.
The hotkey and options may be refs or getters.

Chords accept `requireReset`; sequences accept `timeout`. A one-step
sequence registers as its chord. An app hotkey uses its effective hotkey
from `HotkeysProvider` (including the user's custom hotkey) and its
declared meta and options, and registers nothing while unbound.
`undefined`, `null`, or `''` registers nothing, for an optional shortcut.

## Type Parameters

### T

`T` *extends* `AdapterHotkeyInput`

## Parameters

### hotkey

`IfTypeParameter`\<`T`, `MaybeRefOrGetter`\<`T` \| `null` \| `undefined`\>, `KnownHotkey`\<`T`, `MaybeRefOrGetter`\<`T` \| `null` \| `undefined`\>\>\>

### callback

`HotkeyCallback`\<`IfTypeParameter`\<`T`, `HotkeyCallbackContext`, `AdapterCallbackContextFor`\<`T`\>\>\>

### options?

`IfTypeParameter`\<`T`, `MaybeRefOrGetter`\<`Omit`\<`AdapterHotkeyOptions`\<[`UseHotkeyTarget`](../type-aliases/UseHotkeyTarget.md)\>, `"enabled"`\> & `object`\>, `MaybeRefOrGetter`\<\[`T`\] *extends* \[`AppHotkey`\<`string`, `AppHotkeyBinding`\>\] ? `WithReactiveEnabled`\<`AdapterAppHotkeyOptions`\<`Extract`\<`T`, `AppHotkey`\<`string`, `AppHotkeyBinding`\>\>, [`UseHotkeyTarget`](../type-aliases/UseHotkeyTarget.md)\>\> : `WithReactiveEnabled`\<`AdapterOptionsFor`\<`T`, [`UseHotkeyTarget`](../type-aliases/UseHotkeyTarget.md)\>\>\>\>

## Returns

`void`

## Example

```ts
useHotkey('Mod+S', () => save())
useHotkey(['G', 'G'], () => scrollToTop(), { timeout: 500 })
useHotkey('Escape', () => close(), { enabled: isOpen })
```
