add code for event listener for keypress in ckeditor

前端 未结 6 471
难免孤独
难免孤独 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:29

    I've tested some of the solutions proposed here and I got my anwser when I found this link: http://alfonsoml.blogspot.com.br/2011/03/onchange-event-for-ckeditor.html

    The following code worked like a charm:

    editor.on('contentDom', function()
    {
        editor.document.on('keydown', function( event )
        {
            if ( !event.data.$.ctrlKey && !event.data.$.metaKey )
                somethingChanged();
        }); 
    });
    

提交回复
热议问题