Documentation

Keyboard Shortcuts

Predefined shortcuts

Windows Mac
Remove format ctrl+shift+m ⌘+shift+m
Undo ctrl+z ⌘+z
Redo ctrl+y shift+ctrl+z ⌘+y shift+⌘+z
Bold ctrl+b ⌘+b
Italic ctrl+i ⌘+i
Sup ctrl+h ⌘+h
Sub ctrl+l ⌘+l
Link ctrl+k ⌘+k
Numbered list ctrl+shift+7 ⌘+shift+7
Bulleted list ctrl+shift+8 ⌘+shift+8
Outdent ctrl+[ ⌘+[
Indent ctrl+] ⌘+]
Normal (Paragraph) ctrl+alt+0 ⌘+alt+0
Heading 1 ctrl+alt+1 ⌘+alt+1
Heading 2 ctrl+alt+2 ⌘+alt+2
Heading 3 ctrl+alt+3 ⌘+alt+3
Heading 4 ctrl+alt+4 ⌘+alt+4
Heading 5 ctrl+alt+5 ⌘+alt+5
Heading 6 ctrl+alt+6 ⌘+alt+6

Add your shortcuts

You can add your keyboard shortcuts in addition to the predefined ones. To do this, set the object to the option shortcutsAdd. Let's see an example:

// HTML
<textarea id="content"></textarea>

// Set shortcut object
var myOwnShortcuts = {
    'ctrl+shift+t, meta+shift+t': {
        api: 'module.block.format',
        params: ['blockquote']
    },
    'ctrl+u, meta+u': {
        api: 'module.inline.format',
        params: ['u']
    }
};

// Call Redactor
$R('#content', { shortcutsAdd: myOwnShortcuts });

The shortcutsAdd object gets the shortcut keys for an action, one or more alternative ones, separated by commas. And also arguments are passed:

  • api - the required argument, the API method of Redactor, which will be handling the shortcut;
  • params - optional argument, method parameters as an array.

Add shortcut for plugin

You can add your keyboard shortcuts which will be the handling of your plugin methods. See an example:

// HTML
 <textarea id="content"></textarea>

// Set shortcut object
var myOwnShortcuts = {
    'ctrl+s, meta+s': {
        api: 'plugin.myplugin.save',
        params: ['arg1', 'arg2']
    }
};

// Call Redactor
$R('#content', { plugins: ['myplugin'], shortcutsAdd: myOwnShortcuts, });

And the plugin code:

(function($R)
{
    $R.add('plugin', 'myplugin', {
        init: function(app) {
            this.app = app;
        },
        save: function(arg1, arg2) {
            console.log('shortcut Ctrl+S is triggered');
        }
    });
})(Redactor);

The shortcutsAdd object gets the shortcut keys for an action, one or more alternative ones, separated by commas. And also arguments are passed:

  • func - the required argument, the method of plugin, which will be handling the shortcut;
  • params - optional argument, method parameters as an array.