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

PropertyDescriptionType

key*

The key of the keyboard shortcut.

modifiers*

The modifier keys of the keyboard shortcut.

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.

NameShortcut

Copy

โŒ˜ + โ‡ง + C

CopyDeeplink

โŒ˜ + โ‡ง + C

CopyName

โŒ˜ + โ‡ง + .

CopyPath

โŒ˜ + โ‡ง + ,

Duplicate

โŒ˜ + D

Edit

โŒ˜ + E

MoveDown

โŒ˜ + โ‡ง + โ†“

MoveUp

โŒ˜ + โ‡ง + โ†‘

New

โŒ˜ + N

Open

โŒ˜ + O

OpenWith

โŒ˜ + โ‡ง + O

Pin

โŒ˜ + โ‡ง + P

Refresh

โŒ˜ + R

Remove

โŒƒ + X

RemoveAll

โŒƒ + โ‡ง + X

ToggleQuickLook

โŒ˜ + Y

Keyboard.KeyEquivalent

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" |
  "." |
  "," |
  ";" |
  "=" |
  "+" |
  "-" |
  "[" |
  "]" |
  "{" |
  "}" |
  "ยซ" |
  "ยป" |
  "(" |
  ")" |
  "/" |
  "\\" |
  "'" |
  "`" |
  "ยง" |
  "^" |
  "@" |
  "$" |
  "return" |
  "delete" |
  "deleteForward" |
  "tab" |
  "arrowUp" |
  "arrowDown" |
  "arrowLeft" |
  "arrowRight" |
  "pageUp" |
  "pageDown" |
  "home" |
  "end" |
  "space" |
  "escape" |
  "enter" |
  "backspace";

KeyEquivalent of a Shortcut

Keyboard.KeyModifier

KeyModifier: "cmd" | "ctrl" | "opt" | "shift";

Modifier of a Shortcut

Last updated