add code for event listener for keypress in ckeditor

前端 未结 6 446
难免孤独
难免孤独 2020-12-31 05:52

I need to add an event listener for keypress after the CKEditor is loaded. The code is something like:

CKEDITOR.instances.editor1.document.on(\'key\', fu         


        
6条回答
  •  礼貌的吻别
    2020-12-31 06:05

    If the keydown logic makes sense for a given plugin, you can include it in the plugin's definition:

    CKEDITOR.plugins.add('customPlugin', {
        // definition keys...
        init: function( editor ) {
            // Plugin logic
            ...
    
        // Register a  keydown event handler -- http://docs.ckeditor.com/#!/api/CKEDITOR.editor-event-key
        editor.on('key', function(event) {
            console.log('CKEDITOR keydown event from customPlugin'); // successfully captures keydown when registered from plugin
        }
    });
    

提交回复
热议问题