# defineHotkey

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

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

Defined in: [packages/ember-hotkeys/src/defineHotkey.ts:25](https://github.com/TanStack/hotkeys/blob/main/packages/ember-hotkeys/src/defineHotkey.ts#L25)

Checks one hotkey for `useHotkeys` or `onHotkeys` by the kind of its hotkey,
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.

## Type Parameters

### T

`T` *extends* `AdapterHotkeyInput`

## Parameters

### definition

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

## Returns

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

## Example

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

// In a component: `shortcuts = [play]`, then `{{useHotkeys this.shortcuts}}`
```
