# useHotkey

Hook that registers a keyboard shortcut for the current Player

## Import

```tsx
import { useHotkey } from "@videojs/react";
```

## Usage

Call the hook inside `Player` with the accepted keys and activation callback.

```tsx
function CustomPlayHotkey() {
  useHotkey({
    keys: "k",
    onActivate: (_event, key) => console.log(`Activated by ${key}`),
  });

  return null;
}
```

Shortcuts target the player by default and accept repeated keydown events. Set `target` to `"document"`, `repeatable` to `false`, or `disabled` to change those behaviors. The hook still requires a surrounding `Player` for its coordinator.

## API Reference

`useHotkey(options): void`

### Parameters

| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `options` (required) | `{ keys: string; onActivate: ((event: KeyboardEvent, key: string) => void); target?: 'player' \| 'document'; repeatable?: boolean; disabled?: boolean }` | — | Shortcut keys, activation callback, scope, repeat behavior, and disabled state. |

### Return Value

`void`

---

React documentation: https://videojs.org/docs/framework/react/llms.txt
All documentation: https://videojs.org/llms.txt
