CKEDITOR :使用 blockedKeystrokes 限制键
CKEDITOR : Restrict keys using blockedKeystrokes
我在 CKEditor 中限制 ALT 和 WINDOWS 键时遇到问题。
我现在的方法是这样的
config.blockedKeystrokes =[1114203,18];
//18 ==> ALT 1114203 ==> WINDOWS
(OR)
config.blockedKeystrokes =[1114203,CKEDITOR.ALT];
但是,这些对我不起作用。
我现在该怎么办?
-谢谢
试试这个在我的情况下有效:-
4456466 是 alt.
的键码
CKEDITOR.on('instanceCreated', function(e) {
e.editor.on('key', function (event) {
console.log(event.data.keyCode);
if (event.data.keyCode == 4456466) {
console.log("here");
event.cancel();
}
});
});
如果您想阻止这些密钥,我建议您使用密钥侦听器并根据代码阻止它们。请注意,当编辑器实例完全初始化(instanceReady
事件)时应该附加监听器,而不仅仅是创建。
var editor = CKEDITOR.replace( 'editor1', {});
editor.on('instanceReady', function( e ) {
e.editor.on( 'key', function ( event ) {
var key = event.data.keyCode;
if ( key == 4456466 || key == 91 ) {
//console.log( "here" );
event.cancel();
}
});
});
我在 CKEditor 中限制 ALT 和 WINDOWS 键时遇到问题。
我现在的方法是这样的
config.blockedKeystrokes =[1114203,18];
//18 ==> ALT 1114203 ==> WINDOWS
(OR)
config.blockedKeystrokes =[1114203,CKEDITOR.ALT];
但是,这些对我不起作用。
我现在该怎么办?
-谢谢
试试这个在我的情况下有效:- 4456466 是 alt.
的键码 CKEDITOR.on('instanceCreated', function(e) {
e.editor.on('key', function (event) {
console.log(event.data.keyCode);
if (event.data.keyCode == 4456466) {
console.log("here");
event.cancel();
}
});
});
如果您想阻止这些密钥,我建议您使用密钥侦听器并根据代码阻止它们。请注意,当编辑器实例完全初始化(instanceReady
事件)时应该附加监听器,而不仅仅是创建。
var editor = CKEDITOR.replace( 'editor1', {});
editor.on('instanceReady', function( e ) {
e.editor.on( 'key', function ( event ) {
var key = event.data.keyCode;
if ( key == 4456466 || key == 91 ) {
//console.log( "here" );
event.cancel();
}
});
});