问题
My plugin defines a command to paste some data and generate a link from it.
Is there any way to make a keyboard shortcut for it? I can't find anything that works.
I cannot get this to work.
Running this from my plugin definition doesn't work either
CKEDITOR.config.keystrokes.append([CKEDITOR.CTRL + CKEDITOR.SHIFT + 108, 'pasteLotusLink']);
Nor trying to get at least bold to work from c-q:
editor.keystrokeHandler.keystrokes[CKEDITOR.CTRL + 113, 'bold'];
回答1:
For 4.x, use editor.setKeystroke:
CKEDITOR.plugins.add( 'foo', {
init: function( editor ) {
editor.setKeystroke( CKEDITOR.CTRL + 81, 'bold' ); // CTRL+Q
}
} );
For 3.x:
CKEDITOR.plugins.add( 'foo', {
init: function( editor ) {
editor.on( 'instanceReady', function( evt ) {
evt.removeListener();
this.keystrokeHandler.keystrokes[ CKEDITOR.CTRL + 81 ] = 'bold'; // CTRL+Q
} );
}
} );
来源:https://stackoverflow.com/questions/17706086/how-can-i-add-a-keyboard-shortcut-for-my-command-in-ckeditor-3