# Shortcuts

> Every key and Markdown rule, generated from the modules this site registers.

`Mod` is <kbd>⌘</kbd> on Apple devices and <kbd>Ctrl</kbd> elsewhere. These tables are generated from the registered modules, so they always match what the editor does.

## Everywhere

| Keys | From |
| --- | --- |
| `⏎` | core |
| `⇧⏎` | core |
| `Backspace` | core |
| `Delete` | core |
| `Tab` | core |
| `⇧Tab` | core |
| `Escape` | core |
| `⌘Z` | core |
| `⌘⇧Z` | core |
| `⌘Y` | core |
| `⌘A` | core |
| `⌘⌥0` | core |
| `⌘⇧↑` | dnd |
| `⌘⇧↓` | dnd |
| `⌘⌥1` | [heading](#/docs/modules/blocks/heading) |
| `⌘⌥2` | [heading](#/docs/modules/blocks/heading) |
| `⌘⌥3` | [heading](#/docs/modules/blocks/heading) |
| `⌘B` | [bold](#/docs/modules/marks/bold) |
| `⌘I` | [italic](#/docs/modules/marks/italic) |
| `⌘⇧S` | [strike](#/docs/modules/marks/strike) |
| `⌘E` | [code](#/docs/modules/blocks/code) |
| `⌘K` | [link](#/docs/modules/marks/link) |

## Inside a block

Some keys mean something different depending on where the caret is — <kbd>Tab</kbd> moves between table cells, <kbd>⏎</kbd> keeps the indentation in code:

| Keys | Inside |
| --- | --- |
| `⌘⏎` | [todo](#/docs/modules/blocks/todo) |
| `⏎` | [code](#/docs/modules/blocks/code) |
| `Tab` | [code](#/docs/modules/blocks/code) |
| `⇧Tab` | [code](#/docs/modules/blocks/code) |
| `⌘⏎` | [code](#/docs/modules/blocks/code) |
| `Tab` | [table](#/docs/modules/blocks/table) |
| `⇧Tab` | [table](#/docs/modules/blocks/table) |
| `⏎` | [table](#/docs/modules/blocks/table) |
| `↑` | [table](#/docs/modules/blocks/table) |
| `↓` | [table](#/docs/modules/blocks/table) |
| `Backspace` | [table](#/docs/modules/blocks/table) |
| `Delete` | [table](#/docs/modules/blocks/table) |
| `⌘⇧↑` | [table](#/docs/modules/blocks/table) |
| `⌘⇧↓` | [table](#/docs/modules/blocks/table) |
| `⏎` | [math](#/docs/modules/blocks/math) |

## As you type

At the start of an empty paragraph, these turn it into another block:

| Typed at the start | Becomes |
| --- | --- |
| `#␣` `##␣` `###␣` | [heading](#/docs/modules/blocks/heading) |
| `[]␣` `[ ]␣` `[x]␣` | [todo](#/docs/modules/blocks/todo) |
| `-␣` `*␣` `+␣` | [list](#/docs/modules/blocks/list) |
| `1.␣` `1)␣` | [list](#/docs/modules/blocks/list) |
| `>␣` `"␣` | [quote](#/docs/modules/blocks/quote) |
| `---` | [divider](#/docs/modules/blocks/divider) |
| \`\`\`js␣ \`\`\`␣ | [code](#/docs/modules/blocks/code) |
| `$$␣` | [math](#/docs/modules/blocks/math) |

Inside text, a closed pair of delimiters becomes a mark the moment you type the closing one:

| Typed | Becomes |
| --- | --- |
| `$text$` | [math](#/docs/modules/blocks/math) |
| `**text**` | [bold](#/docs/modules/marks/bold) |
| `_text_ or *text*` | [italic](#/docs/modules/marks/italic) |
| `~~text~~` | [strike](#/docs/modules/marks/strike) |
| \`text\` | [code](#/docs/modules/blocks/code) |

One undo turns any of these conversions back into the characters you typed.

## Selecting blocks

- <kbd>Esc</kbd> selects the block the caret is in; <kbd>⇧↑</kbd> and <kbd>⇧↓</kbd> grow or shrink the selection; <kbd>↑</kbd> and <kbd>↓</kbd> move it.
- <kbd>⌘A</kbd> selects the block's text, then every block.
- Drag across text, or <kbd>⇧</kbd>-click, to select whole blocks.
- With blocks selected: <kbd>Backspace</kbd> deletes them, <kbd>Tab</kbd> and <kbd>⇧Tab</kbd> nest them, <kbd>⌘⇧↑</kbd> and <kbd>⌘⇧↓</kbd> move them, and the <kbd>⌘⌥</kbd> shortcuts turn them into another type — each as one undo step.

## Your own keys

```js save-key.js
import { Editor } from 'verbal-editor';

const editor = new Editor();
editor.on('key', ({ name }) => {
  if (name !== 'Mod-s') return false;
  localStorage.setItem('note', JSON.stringify(editor.getDoc()));
  return true; // claimed: nothing else handles it
});
```
