# defineHotkey

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

```ts
function defineHotkey<T>(definition): Readonly<AlpineHotkeyDefinition>;
```

Defined in: [defineHotkey.ts:26](https://github.com/TanStack/hotkeys/blob/main/packages/alpine-hotkeys/src/defineHotkey.ts#L26)

Checks one hotkey for `createHotkeys` as `createHotkey` checks its arguments, and
returns it unchanged. In an array, a hotkey object is checked only when it
is written inline, and it takes the options of both kinds. Here the hotkey
can be a variable, a key no hotkey object has is a type error, and the
callback context and the options follow the kind of the hotkey. The hotkey
and the options are values, as in the array, not getters.

## Type Parameters

### T

`T` *extends* `AdapterHotkeyInput`

## Parameters

### definition

`AdapterHotkeyDefinitionInput`\<`T`, [`AlpineHotkeyTarget`](../type-aliases/AlpineHotkeyTarget.md)\>

## Returns

`Readonly`\<[`AlpineHotkeyDefinition`](../type-aliases/AlpineHotkeyDefinition.md)\>

## Example

```ts
const play = defineHotkey({
  hotkey: { default: 'Space', alternates: ['K'] },
  callback: () => togglePlay(),
  options: { requireReset: true },
})

scope.createHotkeys([play])
```
