2014-01-07 13 views

回答

4

你可以嘗試創建CKEditor的實例綁定onkeypress事件事件之前,下面的代碼:

CKEDITOR.on('instanceCreated', function(cke) { 
cke.editor.on('contentDom', function() { 
    if(cke.editor.name == "YourIntanceName") // YourIntanceName = name of teaxtarea 
    { 
     cke.editor.document.on('keypress', function(e) { 
      var charCode = event.data.getKey(); 
     }); 
    } 
}); 
}); 
+0

謝謝,它的工作。 – Mosiur

+0

爲避免奇怪的問題,最好使用['editable#attachListener'](http://docs.ckeditor.com/#!/api/CKEDITOR.editable-method-attachListener)方法。看到這裏的例子http://docs.ckeditor.com/#!/api/CKEDITOR.editor-event-contentDom。 – Reinmar