Scrivr
GuidesInteractivity

Keyboard Shortcuts

All built-in keyboard shortcuts and how to add or override them.

All shortcuts use Mod as a platform-agnostic modifier — Cmd on macOS, Ctrl on Windows and Linux.


Built-in shortcuts

Text formatting

ShortcutCommandExtension
Mod-btoggleBold()Bold
Mod-itoggleItalic()Italic
Mod-utoggleUnderline()Underline
Mod-Shift-stoggleStrikethrough()Strikethrough
Mod-Shift-htoggleHighlight()Highlight

Block type

ShortcutCommandExtension
Mod-Alt-1Mod-Alt-6setHeading1()setHeading6()Heading
Mod-Alt-0setParagraph()Heading
Mod-Alt-ctoggleCodeBlock()CodeBlock

Alignment

ShortcutCommand
Mod-Shift-lsetAlignLeft()
Mod-Shift-esetAlignCenter()
Mod-Shift-rsetAlignRight()
Mod-Shift-jsetAlignJustify()

Lists

ShortcutAction
Mod-Shift-8Toggle bullet list
Mod-Shift-9Toggle ordered list
TabIndent list item
Shift-TabDedent list item

History

ShortcutCommand
Mod-zundo()
Mod-Shift-zredo()
Mod-yredo() (Windows alias)

Editing

ShortcutAction
Mod-aSelect all
Shift-EnterInsert hard break (line break without splitting the block)
Tab (inside code block)Insert two spaces

Adding a custom shortcut

Register shortcuts in addKeymap(). The key string format follows ProseMirror's prosemirror-keymap conventions.

import { Extension } from '@scrivr/core';

const MyShortcuts = Extension.create({
  name: 'myShortcuts',

  addKeymap() {
    return {
      'Mod-Shift-x': (state, dispatch) => {
        if (dispatch) dispatch(state.tr.insertText('✕'));
        return true;
      },
    };
  },
});

Overriding a built-in shortcut

Register the same key in your extension's addKeymap(). Extensions are resolved in the order they appear in the extensions array — later extensions override earlier ones for the same key.

// Place MyExtension after StarterKit to override Mod-b
const editor = new Editor({
  extensions: [StarterKit, MyExtension],
});

To disable a shortcut entirely, return false from the command:

addKeymap() {
  return {
    'Mod-b': () => false, // disable bold shortcut
  };
},

On this page