如何知道在ckeditor中是否按下了alt键

How to know if alt key is pressed in ckeditor?

本文关键字:alt 是否 何知道 ckeditor      更新时间:2023-09-26

当在ckeditor中按下alt+r时,我正在尝试做一些事情。这是我的代码

CKEDITOR.on('instanceCreated', function(e) {
            e.editor.on('contentDom', function() {
                e.editor.document.on('keydown', function(evt) {
                    var code=evt.data.getKey();
                    if(code==82){
                        if (evt.data.altKey) {
                            alert('ALt + R pressed');
                        }
                    }
                });
            });
        }); 

在按压r时返回82,而CCD_ 1不工作。

使用此:

if (evt.data.getKeystroke() == 88) {//'put value of alt keystroke 88'
    console.log('Alt Key Pressed');
    //Your function call 
}