add code for event listener for keypress in ckeditor

Viewed 26262

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', function(event) {
    /* instructions   */
});

Any idea where can I add the code for that? In which file or in what way?

6 Answers

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