I wanted to get the keyCode on keydown event in ckeditor. My code looks somewhat like this:
editor.document.on( 'keydown', function(event) {
var keycode= event.data.keyCode & ~(CKEDITOR.SHIFT | CKEDITOR.CTRL |CKEDITOR.ALT);
alert('Key:'+keycode);
});
But it always alerts 0. Can’t figure why is it so.?
Also I wanted to use event.preventDefault() from jQuery, but I can’t figure out how to include jQuery library in my plugin.js file. Any suggestions?
This is the correct code if you want to have fun:
Or this if you want to have shorter code:
Regarding preventing default – you don’t need jQuery for this. CKEditor is so huge tool it has built-in DOM library. You can find
preventDefaultmethod in theevt.datafrom the second example.