Skip to content

Commit 62d0e82

Browse files
committed
docs(use-hotkey): add Key Aliases section with full normalization table
1 parent f6a55c3 commit 62d0e82

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

apps/docs/src/pages/composables/system/use-hotkey.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,34 @@ The `useHotkey` composable registers hotkey handlers on the window with automati
6363
</template>
6464
```
6565

66+
## Key Aliases
67+
68+
Key strings are normalized before matching, so you can use human-friendly names instead of exact `KeyboardEvent.key` values:
69+
70+
| Alias | Canonical |
71+
| - | - |
72+
| `esc` | `escape` |
73+
| `return` | `enter` |
74+
| `del` | `delete` |
75+
| `space`, `spacebar` | ` ` (space character) |
76+
| `up` / `down` / `left` / `right` | `arrowup` / `arrowdown` / `arrowleft` / `arrowright` |
77+
| `control` | `ctrl` |
78+
| `command` | `cmd` |
79+
| `option` | `alt` |
80+
| `plus` | `+` |
81+
| `minus`, `hyphen` | `-` |
82+
| `slash` | `/` |
83+
| `underscore` | `_` |
84+
85+
```ts no-filename
86+
// These are equivalent:
87+
useHotkey('escape', close)
88+
useHotkey('esc', close)
89+
90+
useHotkey('ctrl+plus', zoomIn) // matches Ctrl ++
91+
useHotkey('cmd+minus', zoomOut) // matches Cmd +-
92+
```
93+
6694
## Architecture
6795

6896
`useHotkey` builds on `useEventListener` for keyboard event handling:

0 commit comments

Comments
 (0)