# Keyboard shortcuts and the command palette

Every command in Mayhap has a place on the keyboard, and the mouse is the other way to reach it. F1 lists every command with its key, the command palette finds and runs any of them by name, and you may give any command the keys you like.

## Seeing every key

To see every command with its key, press `F1`. A card opens over the page with the commands in groups, named for where their keys work: *File*, *Show*, *Nudge*, *Alternatives*, *Alternatives panel*, *Settle*, *Find*, *Help*, *Editing* and *Moving*. You may also click the keyboard at the right end of the top bar, or choose *Keyboard Shortcuts* in the file menu.

![The Keyboard shortcuts card over the page, its commands in groups, each with its key](https://mayhap.app/build/assets/shortcuts-BKFFNpnE.webp)

The card always shows the keys as they are now. If you've given a command keys of your own, those are the ones listed, and a command without a key shows a dash. Press `Esc` or `F1` again, or click outside the card, to close it.

Don't worry about learning the keys up front. Whenever you do something from a menu that has a key, a hint in the bottom bar names that key, once.

## Running a command by name

The command palette finds any command by name and runs it. Press `Ctrl+K / ⌘K` or `Ctrl+Shift+P / ⇧⌘P`, and a card with a search field opens under the top bar. It lists every command from the keyboard shortcuts, each with its key.

![The command palette with version typed, listing the commands that hold it, each with its key](https://mayhap.app/build/assets/palette-C410o_n2.webp)

As you type, the list keeps the commands that hold every word you've typed, in any order. Parts of words are enough. For example, type *pdf* and *Export PDF…* is left; type *par st* and you get *Start of the paragraph*.

Press `↑` or `↓` to pick a command, then `Return` to run it. It runs where you were, exactly as its key would there, so a command with nothing to act on does nothing. `Esc` or a click outside closes the palette and puts you back where you were.

While text is selected, `Ctrl+K / ⌘K` makes a link instead. To open the palette then, press `Ctrl+Shift+P / ⇧⌘P`.

## Keys at a glance

Sometimes you may only need the key for a button you're looking at. Hold `Ctrl / ⌘` on its own for half a second, and each control in the top and bottom bars shows its key in a small badge. They're written without the key you're already holding: *1*, *2* and *3* for *Alternatives*, *Nudge* and *Aside*. Let go, press another key or click, and they're gone.

If you'd rather not see them, turn off *Show keys while holding Ctrl* in Settings › Look.

## How the keys are laid out

Mayhap's keys follow a pattern, so a key tells you what kind of thing it does:

- Everyday actions take one modifier: `Ctrl+S / ⌘S` saves and `Ctrl+J / ⌘J` jots a thought.
- Adding Shift acts on the selection, or does a bigger version of the same thing: `Ctrl+Shift+A / ⇧⌘A` makes versions of the selected words, and `Ctrl+Shift+S / ⇧⌘S` saves as a new file.
- Ctrl with Alt changes the view, and sets headings with its digits: `Ctrl+Alt+M / ⌥⌘M` shows Markdown's marks and `Ctrl+Alt+2 / ⌥⌘2` makes a second-level heading.
- Alt steps through things in place: `Alt+↓ / ⌥↓` shows the next version at the caret, and `Alt+N / ⌘]` goes to Nudge's next flag.

The bottom bar's panels are numbered in their order: `Ctrl+1 / ⌘1` for *Alternatives*, `Ctrl+2 / ⌘2` for *Nudge*, `Ctrl+3 / ⌘3` for *Aside*, and `Ctrl+4 / ⌘4` for *History* beside them.

## Changing a key

Any command in the keyboard shortcuts may be given other keys, or none. So may the keys that work inside menus and inside Settings. To get started, open Settings with `Ctrl+, / ⌘,` and choose *Shortcuts*. Every command is listed in its group, each key shown as a chip.

To find a command, type in *Search commands or keys*. It finds a name or a key, so typing *ctrl j* finds whatever `Ctrl+J / ⌘J` does now.

Next, click the chip you'd like to change, or move to it and press `Return`. It says *Press keys…*, and the next key you press takes its place. For example, if you would like *Jot a thought* on `F9` as well, search for *jot*, click the *+* beside its key and press `F9`. Pressing `Esc` while a chip waits leaves the key as it was.

A few things to know as you go:

- A command without a key shows a dashed *no key* chip. Click it to give the command one.
- To take a key off, move to its chip and press `Backspace` or `Delete`.
- *Reset* shows beside a command whose keys you've changed, and gives it its default keys back.
- A key that another command uses in the same place asks first, under the row: *Ctrl+J is Jot a thought.* Choose *Use it here* to move the key, or *Cancel*.
- A key that types a character on its own, such as a letter, is never taken. The chip goes on waiting and tells you to hold a modifier with it.

Each change applies at once, in every window, and is saved straight away.

## The keymap file

If you prefer to edit a file, your keys live in *keymap.json*, beside *settings.json*. While *Shortcuts* is open, *Open keymap.json* at the foot of the sections opens it in your system's app for it. You can learn where the folder is in [Settings](https://mayhap.app/guide/settings#file).

The file holds only your changes, never the defaults. It's grouped by where the keys work, under the names *file*, *show*, *nudge*, *alternatives*, *alternatives-panel*, *settle*, *editing*, *find*, *moving*, *help*, *menus* and *settings*. In each group, a command's id is given a key, a list of keys, or *null* for none. Keys are written as you'd say them, in lowercase with plus signs: *"ctrl+shift+s"*, *"alt+]"*, *"f9"*, or *"cmd+s"* on a Mac.

For example, the line *"jot-a-thought": ["ctrl+j", "f9"]* under *"editing"* gives *Jot a thought* both keys. A command named in the file loses its default keys, so list every key you want it to keep. The file may hold comments, and an editor that reads JSON schemas completes the groups and ids for you from *keymap.schema.json*, which Mayhap writes beside it.

Save the file and every window takes the change a moment later. If a line can't be used, the top bar says so after the document's name, for example *keymap.json has 1 problem*. Click it to see the line and what's wrong, often with a guess at what you meant. Everything else in the file still applies.

## The keys you'll use most

| Command | Linux, Windows | macOS |
| --- | --- | --- |
| Keyboard shortcuts | F1 | F1 |
| Command palette | Ctrl+K, Ctrl+Shift+P | ⌘K, ⇧⌘P |
| Settings… | Ctrl+, | ⌘, |
| File menu | Alt+F | no key |
| New document | Ctrl+N | ⌘N |
| Open… | Ctrl+O | ⌘O |
| Recent files | Ctrl+Shift+O | ⇧⌘O |
| Save | Ctrl+S | ⌘S |
| Save As… | Ctrl+Shift+S | ⇧⌘S |
| Alternatives panel | Ctrl+1 | ⌘1 |
| Nudge | Ctrl+2 | ⌘2 |
| Aside | Ctrl+3 | ⌘3 |
| History | Ctrl+4 | ⌘4 |
| Alternatives for selection | Ctrl+Shift+A | ⇧⌘A |
| Next / previous version at the caret | Alt+↓ / Alt+↑ | ⌥↓ / ⌥↑ |
| Alternatives layer | Ctrl+Alt+A | ⌥⌘A |
| Markdown marks | Ctrl+Alt+M | ⌥⌘M |
| Mark as maybe / Keep it | Ctrl+Shift+M, Ctrl+/ | ⇧⌘M, ⌘/ |
| Set it aside | Ctrl+Shift+X | ⇧⌘X |
| Jot a thought | Ctrl+J | ⌘J |
| Settle | Ctrl+E | ⌘E |
| Focus | Ctrl+Shift+D | ⇧⌘D |
| Full screen | F11 | ⌃⌘F |
| Find | Ctrl+F | ⌘F |
| Replace | Ctrl+H | ⌥⌘F |
| Find in folder | Ctrl+Shift+F | ⇧⌘F |
| Bold / Italic | Ctrl+B / Ctrl+I | ⌘B / ⌘I |
| Link… | Ctrl+K on selected text, Ctrl+Shift+K | ⌘K on selected text, ⇧⌘K |
| Undo | Ctrl+Z | ⌘Z |
| Redo | Ctrl+Shift+Z, Ctrl+Y | ⇧⌘Z |
| Close the window | Ctrl+W | ⌘W |
| Quit | Ctrl+Q | ⌘Q |
