# Keyboard Shortcuts

This page lists every key combination `MDEditor` intercepts and what the `hotKey` option affects.

## How Combos Are Matched

`editorKeydown` turns the key event into a string and looks it up: `metaKey` or `ctrlKey` both become `cmd+`, followed by `shift+`, then `event.key` in lowercase. macOS `Cmd` and Windows/Linux `Ctrl` therefore behave the same.

## Formatting Shortcuts (when `hotKey: true`)

| Combo | Method |
|---|---|
| `Cmd/Ctrl+B` | `bold()` |
| `Cmd/Ctrl+I` | `italic()` |
| `Cmd/Ctrl+Shift+X` | `strikethrough()` |
| `Cmd/Ctrl+U` | `underline()` |
| `Cmd/Ctrl+M` | `marker()` |
| `Cmd/Ctrl+K` | `code()` |
| `Cmd/Ctrl+↑` | `sup()` |
| `Cmd/Ctrl+↓` | `sub()` |

A shortcut's event carries the modifier, so these insert HTML tags (such as `<b></b>`) rather than Markdown markers; see [Formatting Methods](/editor-formatting).

## Editing Keys (always active)

| Key | Action |
|---|---|
| `Cmd/Ctrl+Z` | `undo()` |
| `Cmd/Ctrl+Shift+Z` | `redo()` |
| `Cmd/Ctrl+A` | `selectAll()`, selecting the editor content only |
| `Cmd/Ctrl+S` | `save()`; see [Content and Files](/editor-content) |
| `Tab` | `indent()`: inserts 4 spaces at the caret |
| `Cmd/Ctrl+]` | `rowIndent()`: inserts 4 spaces at the start of every selected row |
| `Enter` | `wrap()`: splits the row at the caret |
| `Backspace` | `backspace()`: deletes the selection or the previous character, or merges with the previous row at a row start |
| `F5`, `Cmd/Ctrl+R` | Intercepted; the page does not reload |

## Default Behavior

- Every active combo in these tables prevents the browser default (e.g. `Cmd+B`, or `Cmd+S` saving the web page)
- Keys not in the tables keep the browser default and are handled by `contentEditable`
- Pressing `Cmd` / `Ctrl` alone does nothing
- `F5` and `Cmd/Ctrl+R` are intercepted only while the editor has focus; to block them page-wide, set `preventRefresh: true`

## Disabling Formatting Shortcuts

```javascript
new MDEditor({ id: "editor", hotKey: false });
```

`hotKey: false` disables only the "Formatting Shortcuts" table; editing keys keep working. Disabled combos are no longer intercepted and fall back to the browser's `contentEditable` default (for example, `Cmd/Ctrl+B` may let the browser apply bold to the DOM directly), bypassing NanoMD's undo history.
