--- title: Register Hotkeys with useHotkey and useHotkeys in Octane id: hotkeys description: Register keyboard shortcuts in Octane with useHotkey and useHotkeys. Write chords and sequences, set options, turn hotkeys on and off, and listen on one element. --- `useHotkey` registers a keyboard shortcut while the component that calls it is mounted, and `useHotkeys` registers several. Both hooks take the same hotkeys and options. To register hotkeys outside Octane components, use the [hotkey manager](./hotkey-manager). ## Chords and sequences A hotkey is one of two kinds: - A **chord** is keys pressed together, such as `'Mod+S'`, or a single key, such as `'Escape'`. - A **sequence** is chords pressed one after another, such as `['G', 'H']`. Write it as an array of chords. ```tsx useHotkey('Mod+K', () => openSearch()) // Mod and K together useHotkey(['G', 'H'], () => goHome()) // G, then H ``` Every hook and option in this guide accepts both kinds, and most examples use chords. [Sequences](./sequences) covers how sequences match, the time allowed between steps, and sequences that start with the same chord. ## Register a hotkey Call `useHotkey` with a hotkey and a callback: ```tsx import { useHotkey } from '@tanstack/octane-hotkeys' function Editor() @{ useHotkey('Mod+S', () => saveDocument())