如何使用组合键在 CK 编辑器中使用 'key' 事件调用自定义方法

How to use combination of keys to call custom methods in CK Editor using 'key' event

我需要在 CK 编辑器中使用 "CTRL + P" 等组合键调用一个自定义方法。我尝试了像 "Enter" 这样的单键按下事件及其工作,但我的要求是使用组合键。有什么办法可以实现吗?

                            ev.editor.on( 'key', function( e ) {
                                var evtobj = window.event ? event : e
                                if( evtobj.data.keyCode === 13 ) {
                                    ev.editor.execCommand( 'addCustomWidget' );
                                }
                            } );

使用setKeystroke()

Assigns keystrokes associated with editor commands.

假设您有一个名为 editor1:

的 CKEditor 实例
CKEDITOR.instances.editor1.on('instanceReady', function(evt) {
    evt.editor.setKeystroke(CKEDITOR.CTRL + 80, 'addCustomWidget'); // CTRL + P
});