Keyboard
The Keyboard APIs are useful to make your actions accessible via the keyboard shortcuts. Shortcuts help users to use your command without touching the mouse.

API Reference

KeyboardShortcut

A keyboard shortcut is defined by one or more modifier keys (command, control, etc.) and a single key equivalent (a character or special key). See KeyModifier and KeyEquivalent for supported values.

Example

1
import { ActionPanel, Detail } from "@raycast/api";
2
3
export default function Command() {
4
return (
5
<Detail markdown="Let's play some games 👾" actions={
6
<ActionPanel title="Game controls">
7
<ActionPanel.Item
8
title="Up"
9
shortcut={{ modifiers: ["opt"], key: "arrowUp" }}
10
onAction={() => console.log("Go up")}
11
/>
12
<ActionPanel.Item
13
title="Down"
14
shortcut={{ modifiers: ["opt"], key: "arrowDown" }}
15
onAction={() => console.log("Go down")}
16
/>
17
<ActionPanel.Item
18
title="Left"
19
shortcut={{ modifiers: ["opt"], key: "arrowLeft" }}
20
onAction={() => console.log("Go left")}
21
/>
22
<ActionPanel.Item
23
title="Right"
24
shortcut={{ modifiers: ["opt"], key: "arrowRight" }}
25
onAction={() => console.log("Go right")}
26
/>
27
</ActionPanel>}
28
/>
29
);
30
}
Copied!

Properties

Name
Type
Required
Description
key
Yes
The key of the keyboard shortcut.
modifiers
KeyModifier[]
Yes
The modifier keys of the keyboard shortcut.

KeyEquivalent

1
KeyEquivalent: "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "." | "," | ";" | "=" | "+" | "-" | "[" | "]" | "{" | "}" | "«" | "»" | "(" | ")" | "/" | "\\" | "'" | "`" | "§" | "^" | "@" | "quot; | "return" | "delete" | "deleteForward" | "tab" | "arrowUp" | "arrowDown" | "arrowLeft" | "arrowRight" | "pageUp" | "pageDown" | "home" | "end" | "space" | "escape" | "enter" | "backspace"
Copied!
KeyEquivalent of a KeyboardShortcut

KeyModifier

1
KeyModifier: "cmd" | "ctrl" | "opt" | "shift"
Copied!
Modifier of a KeyboardShortcut
Last modified 1d ago