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
import { Action, ActionPanel, Detail, Keyboard } from "@raycast/api";
export default function Command() {
return (
<Detail
markdown="Let's play some games πΎ"
actions={
<ActionPanel title="Game controls">
<Action title="Up" shortcut={{ modifiers: ["opt"], key: "arrowUp" }} onAction={() => console.log("Go up")} />
<Action
title="Down"
shortcut={{ modifiers: ["opt"], key: "arrowDown" }}
onAction={() => console.log("Go down")}
/>
<Action
title="Left"
shortcut={{ modifiers: ["opt"], key: "arrowLeft" }}
onAction={() => console.log("Go left")}
/>
<Action
title="Right"
shortcut={{ modifiers: ["opt"], key: "arrowRight" }}
onAction={() => console.log("Go right")}
/>
<Action title="Open" shortcut={Keyboard.Shortcut.Common.Open} onAction={() => console.log("Open")} />
</ActionPanel>
}
/>
);
}Properties
If the shortcut contains some "ambiguous" modifiers (eg. ctrl, or cmd, or windows), you will need to specify the shortcut for both platforms:
Keyboard.Shortcut.Common
A collection of shortcuts that are commonly used throughout Raycast. Using them should help provide a more consistent experience and preserve muscle memory.
Copy
β + β§ + C
ctrl + shift + C
CopyDeeplink
β + β§ + C
ctrl + shift + C
CopyName
β + β§ + .
ctrl + alt + C
CopyPath
β + β§ + ,
alt + shift + C
Save
β + S
ctrl + S
Duplicate
β + D
ctrl + shift + S
Edit
β + E
ctrl + E
MoveDown
β + β§ + β
ctrl + shift + β
MoveUp
β + β§ + β
ctrl + shift + β
New
β + N
ctrl + N
Open
β + O
ctrl + O
OpenWith
β + β§ + O
ctrl + shift + O
Pin
β + β§ + P
ctrl + .
Refresh
β + R
ctrl + R
Remove
β + X
ctrl + D
RemoveAll
β + β§ + X
ctrl + shift + D
ToggleQuickLook
β + Y
ctrl + Y
Keyboard.KeyEquivalent
KeyEquivalent of a Shortcut
Keyboard.KeyModifier
Modifier of a Shortcut.
Note that "alt" and "opt" are the same key, they are just named differently on macOS and Windows.
Last updated

