# The editor's keyboard shortcuts

Source: https://api-genie.dev/docs/reference/editor/keyboard-shortcuts
See also: [The editor's hosts](https://api-genie.dev/docs/reference/editor/hosts.md).

Since 0.13.0, `?` in the API Genie editor lists the shortcuts of the host it runs in. Each host
takes other keys for itself, so each has its own set:

- **Web**: Open a spec, Save and the View menu's commands take the same keys as on the desktop.
  It has no New spec or Close the spec, since the browser keeps Ctrl+N and Ctrl+W, and no Save
  as, since a page can only write the files it opened. Ctrl+O needs the File System Access API
  (Chrome, Edge and other Chromium browsers).
- **Desktop**: the menu bar runs its shortcuts, as its items show.
- **VS Code**: VS Code keeps its own keys, such as Ctrl+B for its side bar. The editor answers
  Ctrl+S, by asking VS Code to save, and `/` and `?`.

Ctrl+N / Cmd+N means Ctrl on Windows and Linux, Cmd on macOS. The web editor takes either on
any system.

<!-- shortcuts: generated by src/apps/app_editor/src/app/shortcuts.test.ts from shortcuts.ts; UPDATE_GOLDEN=1 npm test rewrites it -->
| Command | Web | Desktop | VS Code |
| --- | --- | --- | --- |
| New spec | None | Ctrl+N / Cmd+N | None |
| Open a spec | Ctrl+O / Cmd+O | Ctrl+O / Cmd+O | None |
| Close the spec | None | Ctrl+W / Cmd+W | None |
| Save | Ctrl+S / Cmd+S | Ctrl+S / Cmd+S | Ctrl+S / Cmd+S |
| Save the current file as | None | Ctrl+Shift+S / Cmd+Shift+S | None |
| Undo | Ctrl+Z / Cmd+Z (in the code view; a form field keeps its own undo and redo) | Ctrl+Z / Cmd+Z | Ctrl+Z / Cmd+Z (VS Code's) |
| Redo | Ctrl+Shift+Z / Cmd+Shift+Z, Ctrl+Y / Cmd+Y (in the code view; a form field keeps its own undo and redo) | Ctrl+Shift+Z / Cmd+Shift+Z; Ctrl+Y / Cmd+Y (in the code view; a form field keeps its own undo and redo) | Ctrl+Shift+Z / Cmd+Shift+Z, Ctrl+Y / Cmd+Y (VS Code's) |
| Show or hide the side bar | Ctrl+B / Cmd+B | Ctrl+B / Cmd+B | None |
| Show or hide the bottom panel | Ctrl+J / Cmd+J | Ctrl+J / Cmd+J | None |
| Show or hide the right pane | Ctrl+Alt+B / Cmd+Option+B | Ctrl+Alt+B / Cmd+Option+B | None |
| Search the spec outline | `/` | `/` | `/` |
| Show the keyboard shortcuts | `?` | `?` | `?` |
<!-- /shortcuts -->

`/` and `?` do nothing while you type in a field or in the code view. The keys with Ctrl or Cmd
work there too. While a dialog of the editor is open, the page answers only Ctrl+S and `?`. The
desktop's menu bar answers its keys whatever is open.

Undo and redo in the code view, and from the desktop's Edit menu, take back the last change of
the files, whether a form or the code made it. In a form field you are typing in, they take back
that typing.

The reference pages that the doc components publish have
[shortcuts of their own](/docs/reference/doc-components/keyboard-shortcuts). The editor's preview
shows single operations and schemas, which take no shortcuts.
