EditingKeystrokeHandler
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' );
Properties
module:core/editingkeystrokehandler~EditingKeystrokeHandler#editorThe editor instance.
Methods
constructor( editor )module:core/editingkeystrokehandler~EditingKeystrokeHandler#constructordestroy() → voidinheritedmodule:core/editingkeystrokehandler~EditingKeystrokeHandler#destroylistenTo( emitter ) → voidinheritedmodule:core/editingkeystrokehandler~EditingKeystrokeHandler#listenToStarts listening for
keydownevents from a given emitter.Parameters
emitter : Window | Emitter | HTMLElement
Returns
void
press( keyEvtData ) → booleaninheritedmodule:core/editingkeystrokehandler~EditingKeystrokeHandler#pressTriggers a keystroke handler for a specified key combination, if such a keystroke was defined.
Parameters
keyEvtData : Readonly<KeystrokeInfo>Key event data.
Returns
booleanWhether the keystroke was handled.
set( keystroke, callback, options = { [options.priority] } ) → voidmodule:core/editingkeystrokehandler~EditingKeystrokeHandler#setRegisters a handler for the specified keystroke.
The handler can be specified as a command name or a callback.
Parameters
keystroke : string | Array<string | number>Keystroke defined in a format accepted by the
parseKeystrokefunction.callback : EditingKeystrokeCallbackIf 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 bothpreventDefault()andstopPropagation()of the event.options : objectAdditional options.
Properties[ options.priority ] : PriorityStringThe 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
{}
Returns
void
stopListening( [ emitter ] ) → voidinheritedmodule:core/editingkeystrokehandler~EditingKeystrokeHandler#stopListeningStops listening to
keydownevents from the given emitter.Parameters
[ emitter ] : Window | Emitter | HTMLElement
Returns
void