# createHotkey

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

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

Defined in: [createHotkey.ts:69](https://github.com/TanStack/hotkeys/blob/main/packages/solid-hotkeys/src/createHotkey.ts#L69)

Solid primitive 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 accessors.

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`, `MaybeGetter`\<`T` \| `null` \| `undefined`\>, `KnownHotkey`\<`T`, `MaybeGetter`\<`T` \| `null` \| `undefined`\>\>\>

### callback

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

### options?

`IfTypeParameter`\<`T`, `MaybeGetter`\<[`CreateHotkeyOptions`](../type-aliases/CreateHotkeyOptions.md)\>, `MaybeGetter`\<\[`T`\] *extends* \[`AppHotkey`\<`string`, `AppHotkeyBinding`\>\] ? `AdapterAppHotkeyOptions`\<`Extract`\<`T`, `AppHotkey`\<`string`, `AppHotkeyBinding`\>\>, [`CreateHotkeyTarget`](../type-aliases/CreateHotkeyTarget.md)\> : `AdapterOptionsFor`\<`T`, [`CreateHotkeyTarget`](../type-aliases/CreateHotkeyTarget.md)\>\>\>

## Returns

`void`

## Example

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