Report an issue

EditingKeystrokeHandler (core)



A keystroke handler for editor editing. Its instance is available in keystrokes so plugins can register their keystrokes.

E.g. an undo plugin would do this:

editor.keystrokes.set( 'Ctrl+Z', 'undo' );
editor.keystrokes.set( 'Ctrl+Shift+Z', 'redo' );
editor.keystrokes.set( 'Ctrl+Y', 'redo' );




  • constructor( editor )

    Creates an instance of the keystroke handler.


    editor : Editor
  • set( keystroke, callback, [ options ] = { [options.priority] } )

    Registers a handler for the specified keystroke.

    The handler can be specified as a command name or a callback.


    keystroke : String | Array.<(String | Number)>

    Keystroke defined in a format accepted by the parseKeystroke function.

    callback : function | String

    If a string is passed, then the keystroke will execute a command. If a function, then it will be called with the key event data object and a cancel() helper to both preventDefault() and stopPropagation() of the event.

    [ options ] : Object

    Additional options.

    [ options.priority ] : PriorityString | Number

    The priority of the keystroke callback. The higher the priority value the sooner the callback will be executed. Keystrokes having the same priority are called in the order they were added.

    Defaults to 'normal'

    Defaults to {}