如何在CKEditor 3中为我的命令添加键盘快捷键? [英] How can I add a keyboard shortcut for my command in CKEditor 3?

查看:79
本文介绍了如何在CKEditor 3中为我的命令添加键盘快捷键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的插件定义了一个粘贴一些数据并从中生成链接的命令。

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.

我无法得到这个可以工作。

从我的插件定义运行这个没有'工作

Running this from my plugin definition doesn't work either

CKEDITOR.config.keystrokes.append([CKEDITOR.CTRL + CKEDITOR.SHIFT + 108, 'pasteLotusLink']);

也没有尝试从cq获得至少大胆的工作:

Nor trying to get at least bold to work from c-q:

editor.keystrokeHandler.keystrokes[CKEDITOR.CTRL + 113, 'bold'];


推荐答案

对于4.x,使用 editor.setKeystroke

CKEDITOR.plugins.add( 'foo', {
    init: function( editor ) {
        editor.setKeystroke( CKEDITOR.CTRL + 81, 'bold' ); // CTRL+Q
    }
} );

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
        } );
    }
} );

这篇关于如何在CKEditor 3中为我的命令添加键盘快捷键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆