Skip to content

Commit

Permalink
Address request from @sindresorhus
Browse files Browse the repository at this point in the history
  • Loading branch information
depeele committed Nov 15, 2024
1 parent 7b12d04 commit 69526ab
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
24 changes: 15 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -1469,15 +1469,21 @@ For example, if the user presses the Home key, `key.name` will be set to `home`.
For non-meta keys, the `key.name` will be equivalent to the lower-cased version of `input`.

Currently identified meta keys:
- f1 - f12
- escape
- number (for all number keys 0-9)
- return
- up, down, left, right (arrow keys)
- insert, delete
- home, end
- pageup, pagedown
- space
- `f1` - `f12`
- `escape`
- `number` (for all number keys 0-9)
- `return`
- `up` (arrow keys)
- `down` (arrow keys)
- `left` (arrow keys)
- `right` (arrow keys)
- `insert`
- `delete`
- `home`
- `end`
- `pageup`
- `pagedown`
- `space`


###### key.leftArrow
Expand Down
26 changes: 25 additions & 1 deletion src/hooks/use-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,31 @@ import useStdin from './use-stdin.js';
*/
export type Key = {
/**
* The name of the key that was pressed.
* The interpreted name of the key that was pressed. This is primarily useful
* for meta keys (e.g. Home, End, Insert).
*
* For example, if the user presses the Home key, `key.name` will be set to
* `home`.
*
* For non-meta keys, the `key.name` will be equivalent to the lower-cased
* version of `input`.
*
* Currently identified meta keys:
* - `f1` - `f12`
* - `escape`
* - `number` (for all number keys 0-9)
* - `return`
* - `up` (arrow keys)
* - `down` (arrow keys)
* - `left` (arrow keys)
* - `right` (arrow keys)
* - `insert`
* - `delete`
* - `home`
* - `end`
* - `pageup`
* - `pagedown`
* - `space`
*/
name: string;

Expand Down

0 comments on commit 69526ab

Please sign in to comment.