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.

Types

Keyboard.Shortcut

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
6
markdown="Let's play some games 👾"
7
actions={
8
<ActionPanel title="Game controls">
9
<ActionPanel.Item
10
title="Up"
11
shortcut={{ modifiers: ["opt"], key: "arrowUp" }}
12
onAction={() => console.log("Go up")}
13
/>
14
<ActionPanel.Item
15
title="Down"
16
shortcut={{ modifiers: ["opt"], key: "arrowDown" }}
17
onAction={() => console.log("Go down")}
18
/>
19
<ActionPanel.Item
20
title="Left"
21
shortcut={{ modifiers: ["opt"], key: "arrowLeft" }}
22
onAction={() => console.log("Go left")}
23
/>
24
<ActionPanel.Item
25
title="Right"
26
shortcut={{ modifiers: ["opt"], key: "arrowRight" }}
27
onAction={() => console.log("Go right")}
28
/>
29
</ActionPanel>
30
}
31
/>
32
);
33
}
Copied!

Properties

Property
Description
Type
key*
The key of the keyboard shortcut.
modifiers*
The modifier keys of the keyboard shortcut.

Keyboard.KeyEquivalent

1
KeyEquivalent: "a" |
2
"b" |
3
"c" |
4
"d" |
5
"e" |
6
"f" |
7
"g" |
8
"h" |
9
"i" |
10
"j" |
11
"k" |
12
"l" |
13
"m" |
14
"n" |
15
"o" |
16
"p" |
17
"q" |
18
"r" |
19
"s" |
20
"t" |
21
"u" |
22
"v" |
23
"w" |
24
"x" |
25
"y" |
26
"z" |
27
"0" |
28
"1" |
29
"2" |
30
"3" |
31
"4" |
32
"5" |
33
"6" |
34
"7" |
35
"8" |
36
"9" |
37
"." |
38
"," |
39
";" |
40
"=" |
41
"+" |
42
"-" |
43
"[" |
44
"]" |
45
"{" |
46
"}" |
47
"«" |
48
"»" |
49
"(" |
50
")" |
51
"/" |
52
"\\" |
53
"'" |
54
"`" |
55
"§" |
56
"^" |
57
"@" |
58
"quot; |
59
"return" |
60
"delete" |
61
"deleteForward" |
62
"tab" |
63
"arrowUp" |
64
"arrowDown" |
65
"arrowLeft" |
66
"arrowRight" |
67
"pageUp" |
68
"pageDown" |
69
"home" |
70
"end" |
71
"space" |
72
"escape" |
73
"enter" |
74
"backspace";
Copied!
KeyEquivalent of a Shortcut

Keyboard.KeyModifier

1
KeyModifier: "cmd" | "ctrl" | "opt" | "shift";
Copied!
Modifier of a Shortcut