繁体   English   中英

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

[英]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()

分配与编辑器命令关联的击键。

假设您有一个名为editor1的CKEditor实例:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM