Documentation 1.11.6

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.

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
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

Disabling Formatting Shortcuts

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.

中文