Plate
PlateEditorsCreateTemplates
GitHub16kGitHub
DiscordDiscord
  • Feature Kits
  • Upload Files
  • Plugin
    • Plugin Methods
    • Plugin Shortcuts
    • Plugin Context
    • Plugin Components
    • Plugin Rules
    • Editing Behavior
    • Plugin Input Rules
  • Editor
    • Editor Methods
    • Controlled Value
  • Authored Changes
  • Performance
  • Static Rendering
  • HTML
  • Markdown
  • Form
  • Right-to-left
  • TypeScript
  • Debugging
  • Unit Testing
  • Browser
  • Troubleshooting
  • Locations
  • Transactions
  • Serializing
  • Roots
  • Document Meta
  • Clipboard and Paste
  • Decorations and annotations
  • Schema
  • History
  • PaginationExperimental
  • Annotations
  • DOM Coverage
  • External Text Views
  • Virtualized Rendering

Plugin Shortcuts

PreviousNext

Configure keyboard shortcuts on Plate plugins.

Plugin shortcuts map key combinations to plugin methods or explicit handlers. Plate compiles one immutable, ordered table during plugin setup. Each editable root installs one dispatcher for that table. This guide covers linked methods, custom handlers, overrides, priorities, and default shortcut ownership.

How shortcuts resolve

Each plugin owns a shortcuts object. At resolution time Plate namespaces every shortcut as ${plugin.name}.${shortcutName}.

Plate runs no shortcut for a key event that reports isComposing or carries keyCode 229, the code WebKit sends for the Enter that confirms an IME composition. Plugin onKeyDown handlers still receive the event.

When a shortcut has no handler, Plate looks for a same-named plugin method:

  1. One update method exists: Plate infers update.
  2. One API method exists: Plate infers api.
Plugin MethodsPlugin Context

On This Page

How shortcuts resolveLinked update shortcutsLinked API shortcutsCustom handlersLet the browser handle a keyConfigure existing shortcutsShow a shortcut in UIMultiple shortcutsPriorityEditor-level shortcutsDefault shortcutsAPI Reference
Build your editor
Production-ready AI template and reusable components.
Get all-access
  • Both exist: set target: 'update' | 'api' to disambiguate.
  • Neither exists: plugin compilation reports the invalid shortcut.
  • An explicit target must name an existing route. A custom handler owns dispatch itself, so it cannot also set target.

    Declare handlerless shortcuts after the method they link to. TypeScript validates the capabilities already carried by that plugin descriptor, so the constructor contribution with update or api comes before the .extend({ shortcuts }) call. This real type dependency is why the example uses a later stage. Custom handlers do not need a linked method.

    FieldMeaning
    keysKey combination compiled by Plate's realm-aware matcher. Use a string like 'mod+b', or an array like ['mod+b', 'ctrl+b'] for several combinations.
    handlerExplicit callback receiving { editor, event }.
    targetOptional 'update' or 'api' disambiguation when both same-named routes exist.
    priorityShortcut-local priority. Defaults to 0.
    nullRemoves that named shortcut from the plugin.

    A single digit bound with mod matches that digit's key on a US layout, whatever character Shift or the layout gives it. So mod+shift+0 fires on Windows, where Shift makes the key report ), and mod+1 fires on a French keyboard, where the key reports &. On Windows and Linux, where mod is Control, a binding that adds alt matches only when the key types the digit. Windows reads Control with Alt as AltGr, which types characters on many layouts. To bind a key by its position whatever it types, write its code, such as mod+alt+digit1.

    Linked update shortcuts

    Use a linked update method when the shortcut and plugin update method share a name.

    plugins/signature-plugin.tsx
    import { definePlugin } from 'platejs/react';
     
    export const SignaturePlugin = definePlugin('signature', {
      update: ({ tx }) => ({
        insertSignature: () => {
          tx.text.insert(' - EditorRoot');
        },
      }),
    })
      .extend({
        shortcuts: {
          insertSignature: {
            keys: 'mod+shift+s',
          },
        },
      });
    plugins/signature-plugin.tsx
    import { definePlugin } from 'platejs/react';
     
    export const SignaturePlugin = definePlugin('signature', {
      update: ({ tx }) => ({
        insertSignature: () => {
          tx.text.insert(' - EditorRoot');
        },
      }),
    })
      .extend({
        shortcuts: {
          insertSignature: {
            keys: 'mod+shift+s',
          },
        },
      });

    Pressing Mod+Shift+S runs editor.update((tx) => tx.signature.insertSignature()).

    Linked API shortcuts

    When only the matching API method exists, Plate infers the API route.

    plugins/inspect-plugin.tsx
    import { DebugPlugin } from 'platejs';
    import { definePlugin } from 'platejs/react';
     
    export const InspectPlugin = definePlugin('inspect', {
      api: ({ editor }) => ({
        logText: () => {
          editor
            .plugin(DebugPlugin)
            .api.info('Editor text', undefined, editor.read.text.string([]));
        },
      }),
    })
      .extend({
        shortcuts: {
          logText: {
            keys: 'mod+alt+l',
          },
        },
      });
    plugins/inspect-plugin.tsx
    import { DebugPlugin } from 'platejs';
    import { definePlugin } from 'platejs/react';
     
    export const InspectPlugin = definePlugin('inspect', {
      api: ({ editor }) => ({
        logText: () => {
          editor
            .plugin(DebugPlugin)
            .api.info('Editor text', undefined, editor.read.text.string([]));
        },
      }),
    })
      .extend({
        shortcuts: {
          logText: {
            keys: 'mod+alt+l',
    
    
    

    Pressing Mod+Alt+L calls editor.plugin(InspectPlugin).api.logText().

    Disambiguate collisions

    If an update method and API method share a name, set target: 'update' or target: 'api'. Plate never changes route silently when a second method is added. Call plugin-owned APIs through editor.plugin(Plugin).api.

    Custom handlers

    Use a handler when the shortcut needs the keyboard event, custom branching, or work that should not live as a plugin API or update method. Do not set target on a handler shortcut.

    plugins/draft-plugin.tsx
    import { DebugPlugin } from 'platejs';
    import { definePlugin } from 'platejs/react';
     
    export const DraftPlugin = definePlugin('draft', {
      shortcuts: {
        saveDraft: {
          keys: 'mod+s',
          handler: ({ editor }) => {
            const text = editor.read.text.string([]);
     
            if (text.trim().length === 0) return false;
     
            editor.plugin(DebugPlugin).api.info('Draft text', undefined, text);
     
            return true;
          },
        },
      },
    });
    plugins/draft-plugin.tsx
    import { DebugPlugin } from 'platejs';
    import { definePlugin } from 'platejs/react';
     
    export const DraftPlugin = definePlugin('draft', {
      shortcuts: {
        saveDraft: {
          keys: 'mod+s',
          handler: ({ editor }) => {
            const text = editor.read.text.string([]);
     
            if (text.trim().length === 0) return false;
     
            editor.plugin(DebugPlugin).api.info('Draft text', undefined, text);
     
    
    
    
    
    
    Handler returnsBehavior
    falseNot handled. Plate leaves the event alone and tries the next matching shortcut.
    Anything elseHandled. Plate calls event.preventDefault() and event.stopPropagation(), so the key reaches no other key handler.

    Plate runs shortcuts on keydown. For a keyup action, use the plugin's on.keyUp handler.

    Let the browser handle a key

    A handled shortcut always prevents the browser's own action, and the first matching shortcut whose handler does not return false takes the key. So every plugin that binds the key must let it through. To keep the browser's action on every key press, set each of those shortcuts to null. To keep it only in some places, wrap each plugin's handler with extend and return false there.

    plugins/indent-plugin.tsx
    import { IndentPlugin } from 'platejs/react';
     
    export const AppIndentPlugin = IndentPlugin.extend(({ plugin }) => ({
      shortcuts: {
        tab: {
          keys: 'tab',
          handler: (context) => {
            const block = context.editor.read.nodes.block();
     
            if (block?.[1][0] === 0) return false;
     
            return plugin.shortcuts.tab?.handler?.(context);
          },
        },
      },
    }));
    plugins/indent-plugin.tsx
    import { IndentPlugin } from 'platejs/react';
     
    export const AppIndentPlugin = IndentPlugin.extend(({ plugin }) => ({
      shortcuts: {
        tab: {
          keys: 'tab',
          handler: (context) => {
            const block = context.editor.read.nodes.block();
     
            if (block?.[1][0] === 0) return false;
     
            return plugin.shortcuts.tab?.handler?.(context);
          },
        },
      },
    }));

    With IndentPlugin as the only Tab owner, Tab in the first block is left to the browser, and Tab in any other block indents it. Other plugins bind Tab too, such as ListPlugin, TablePlugin and CodeBlockPlugin, so wrap their Tab shortcuts the same way when they are installed. A shortcut that links to a plugin method has no handler to wrap, so its wrapper calls that method. A shortcut cannot keep a target beside a handler. So when the linked shortcut declares a target, such as CopilotPlugin's accept, set it to null and declare the wrapper under a new name.

    Configure existing shortcuts

    Configure a named shortcut to change its keys.

    plugins/basic-marks.tsx
    import { BoldPlugin } from 'platejs/react';
     
    export const AppBoldPlugin = BoldPlugin.configure({
      shortcuts: {
        toggle: {
          keys: 'mod+shift+b',
        },
      },
    });
    plugins/basic-marks.tsx
    import { BoldPlugin } from 'platejs/react';
     
    export const AppBoldPlugin = BoldPlugin.configure({
      shortcuts: {
        toggle: {
          keys: 'mod+shift+b',
        },
      },
    });

    A configured shortcut keeps each field you leave out.

    Set a shortcut to null to remove it.

    plugins/basic-marks.tsx
    import { ItalicPlugin } from 'platejs/react';
     
    export const AppItalicPlugin = ItalicPlugin.configure({
      shortcuts: {
        toggle: null,
      },
    });
    plugins/basic-marks.tsx
    import { ItalicPlugin } from 'platejs/react';
     
    export const AppItalicPlugin = ItalicPlugin.configure({
      shortcuts: {
        toggle: null,
      },
    });

    The null value removes italic.toggle from the compiled shortcut set.

    Show a shortcut in UI

    Read a plugin's keys from editor.plugin(plugin).shortcuts instead of writing them again, so a rebound shortcut changes its label and a removed one shows none. ariaKeyShortcuts from platejs/dom turns the keys into the value of the aria-keyshortcuts attribute, such as Control+Shift+X, naming only combos the editor's matcher matches on a US layout.

    components/bold-button.tsx
    'use client';
     
    import { ariaKeyShortcuts, usesAppleDOMHotkeys } from 'platejs/dom';
    import { BoldPlugin, useEditor } from 'platejs/react';
    import * as React from 'react';
     
    export function BoldButton() {
      const editor = useEditor();
      const bold = editor.plugin(BoldPlugin);
      const keys = bold.installed ? bold.shortcuts.toggle?.keys : undefined;
      const [platform, setPlatform] = React.useState<'apple' | 'other'>();
     
      React.useEffect(() => {
        setPlatform(usesAppleDOMHotkeys(document) ? 'apple' : 'other');
      }, []);
     
      const shortcuts =
        keys && platform ? ariaKeyShortcuts(keys, { platform }) : undefined;
     
      return (
        <button
          type="button"
          aria-keyshortcuts={shortcuts}
          disabled={!bold.installed}
          title={shortcuts ? `Bold (${shortcuts})` : 'Bold'}
          onClick={() => bold.update.toggle()}
        >
          B
        </button>
      );
    }
    components/bold-button.tsx
    'use client';
     
    import { ariaKeyShortcuts, usesAppleDOMHotkeys } from 'platejs/dom';
    import { BoldPlugin, useEditor } from 'platejs/react';
    import * as React from 'react';
     
    export function BoldButton() {
      const editor = useEditor();
      const bold = editor.plugin(BoldPlugin);
      const keys = bold.installed ? bold.shortcuts.toggle?.keys : undefined;
      const [platform, setPlatform] = React.useState<'apple' | 'other'>();
     
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    Read the shortcut only when installed is true, because reading the shortcuts of a plugin the editor does not have throws. The server has no platform, so the label waits for the first render in the browser. ariaKeyShortcuts returns undefined when it can name no combo, such as mod+shift+0, whose character depends on the keyboard layout. MarkToolbarButton does this for every mark button and shows the keys as ⇧⌘X on Apple devices.

    Multiple shortcuts

    A plugin can declare multiple shortcut names. Keep each name aligned with the method it should call.

    plugins/review-plugin.tsx
    import { definePlugin } from 'platejs/react';
     
    export const ReviewPlugin = definePlugin('review', {
      update: ({ tx }) => ({
        accept: () => tx.text.insert('Accepted'),
        reject: () => tx.text.insert('Rejected'),
      }),
    })
      .extend({
        shortcuts: {
          accept: {
            keys: 'mod+alt+a',
          },
          reject: {
            keys: 'mod+alt+r',
          },
        },
      });
    plugins/review-plugin.tsx
    import { definePlugin } from 'platejs/react';
     
    export const ReviewPlugin = definePlugin('review', {
      update: ({ tx }) => ({
        accept: () => tx.text.insert('Accepted'),
        reject: () => tx.text.insert('Rejected'),
      }),
    })
      .extend({
        shortcuts: {
          accept: {
            keys: 'mod+alt+a',
          },
          reject: {
            keys: 'mod+alt+r',
          },
        },
    

    This creates the compiled shortcut IDs review.accept and review.reject.

    Priority

    Shortcut priority defaults to 0. Set it on a shortcut when two handlers use the same key combination and one should win.

    plugins/priority-plugin.tsx
    import { definePlugin } from 'platejs/react';
     
    export const PriorityPlugin = definePlugin('commandMenu', {
      shortcuts: {
        openCommandMenu: {
          keys: 'mod+k',
          priority: 200,
          handler: ({ editor }) => {
            editor.api.debug.info('Open command menu');
     
            return true;
          },
        },
      },
    });
    plugins/priority-plugin.tsx
    import { definePlugin } from 'platejs/react';
     
    export const PriorityPlugin = definePlugin('commandMenu', {
      shortcuts: {
        openCommandMenu: {
          keys: 'mod+k',
          priority: 200,
          handler: ({ editor }) => {
            editor.api.debug.info('Open command menu');
     
            return true;
          },
        },
      },
    });

    Plate orders the compiled table by shortcut priority, plugin application order, then declaration order. The first handled route wins.

    A digit and a symbol on the same key can match one press. On a French keyboard, Control with the 6 key reports -, so it matches both mod+6 and mod+-. An app that binds both gives the symbol's shortcut a higher priority.

    Editor-level shortcuts

    An editor-wide command that belongs to no feature plugin goes in a small app plugin.

    editor.ts
    import { DebugPlugin } from 'platejs';
    import { createEditor, definePlugin } from 'platejs/react';
     
    const WordCountPlugin = definePlugin('wordCount', {
      shortcuts: {
        reportWordCount: {
          keys: 'mod+shift+c',
          handler: ({ editor }) => {
            const words = editor.read.text
              .string([])
              .trim()
              .split(/\s+/)
              .filter(Boolean);
     
            editor
              .plugin(DebugPlugin)
              .api.info('Word count', undefined, words.length);
     
            return true;
          },
        },
      },
    });
     
    export const editor = createEditor({ plugins: [WordCountPlugin] });
    editor.ts
    import { DebugPlugin } from 'platejs';
    import { createEditor, definePlugin } from 'platejs/react';
     
    const WordCountPlugin = definePlugin('wordCount', {
      shortcuts: {
        reportWordCount: {
          keys: 'mod+shift+c',
          handler: ({ editor }) => {
            const words = editor.read.text
              .string([])
              .trim()
              .split(/\s+/)
              .filter(Boolean);
     
            editor
              .plugin(DebugPlugin)
    
    
    
    
    
    
    
    
    

    This creates the compiled shortcut ID wordCount.reportWordCount.

    Default shortcuts

    PluginShortcut nameKeys
    BoldPlugintoggleMod+B
    ItalicPlugintoggleMod+I
    UnderlinePlugintoggleMod+U
    ParagraphPlugintoggleMod+Alt+0, Mod+Shift+0
    CopilotPluginacceptTab
    CopilotPluginrejectEscape

    Other plugins often expose toggle, insert, or feature-specific transforms without default keys. Add shortcuts in your app when those commands should be keyboard-accessible.

    API Reference

    Shortcut type
    type Shortcut = {
      keys?: string | readonly string[];
      priority?: number;
    } & (
      | {
          handler: (context: {
            editor: Editor;
            event: KeyboardEvent;
          }) => boolean | void;
          target?: never;
        }
      | { handler?: never; target?: 'api' | 'update' }
    );
    Shortcut type
    type Shortcut = {
      keys?: string | readonly string[];
      priority?: number;
    } & (
      | {
          handler: (context: {
            editor: Editor;
            event: KeyboardEvent;
          }) => boolean | void;
          target?: never;
        }
      | { handler?: never; target?: 'api' | 'update' }
    );

    target and handler are mutually exclusive.

    Name shortcuts after plugin-specific transforms or API methods by default, and use handlers only when the keyboard event is part of the behavior.

    },
    },
    });
    return
    true
    ;
    },
    },
    },
    });
    React.useEffect(() => {
    setPlatform(usesAppleDOMHotkeys(document) ? 'apple' : 'other');
    }, []);
    const shortcuts =
    keys && platform ? ariaKeyShortcuts(keys, { platform }) : undefined;
    return (
    <button
    type="button"
    aria-keyshortcuts={shortcuts}
    disabled={!bold.installed}
    title={shortcuts ? `Bold (${shortcuts})` : 'Bold'}
    onClick={() => bold.update.toggle()}
    >
    B
    </button>
    );
    }
    });
    .api.info('Word count', undefined, words.length);
    return true;
    },
    },
    },
    });
    export const editor = createEditor({ plugins: [WordCountPlugin] });