Question

I want to disable some key in CK EDITOR.

I am using CKEDITOR 4.0 & I want to disable some shortcuts keys in CKEDITOR.

e.g. help file opens on Alt + 0

In old version Config Available in Source/plugins/keystroks/plugins.js But not availble in new version.

Was it helpful?

Solution

Using config.keystrokes you can add and remove keystrokes.

From documentation:

// Disable default CTRL + L keystroke which executes link command by default.
config.keystrokes = [
    ...
    [ CKEDITOR.CTRL + 76, null ],                       // CTRL + L
    ...
];

OTHER TIPS

Replace the CKEditor.config.keystrokes with an empty array:

CKEDITOR.config.keystrokes = [];

Or CKeditor already offers a hotkey functionality (see the CKeditor documentation). Using this functionality we can bind keystrokes to CKeditor actions. In order to save, the following line should be added:

CKEDITOR.config.keystrokes = ... [ CKEDITOR.CTRL + 83 /*S*/, null ], ...

I see you have comments on both answers asking about applying changes to all CKEditor instances. The following code should allow you to override settings for all instances

window.onload = function(){
    CKEDITOR.on('instanceReady', function (ev) {
        ev.editor.setKeystroke(CKEDITOR.ALT + 48 /*0*/, false);
    });
}

Every time a CKEDITOR instance is initialized and ready, it will automatically disable alt+0.

There is a list of the ascii codes for the different characters here for reference if you want to disable other keys: http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters

Use the number in the Dec (decimal) column to disable they key in the Glyph column.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top