I am trying to use ckeditor to edit single lines so I don't want users to be able to use the enter key. Does anyone know how to stop the enter key from being used?
I tried $("#text").keypress(function(event){ alert(event.keyCode); });
But it didn't register. Thanks for any help.
Here's what I did. I created a dummy plugin called 'doNothing'. Just create a 'doNothing' directory under 'plugins', then paste the following code into a plugin.js file there.
(function()
{
var doNothingCmd =
{
exec : function( editor )
{
return;
}
};
var pluginName = 'doNothing';
CKEDITOR.plugins.add( pluginName,
{
init : function( editor )
{
editor.addCommand( pluginName, doNothingCmd );
}
});
})();
Add the plugin to your config.js file with config.extraPlugins = 'doNothing';
, then put in
config.keystrokes =
[
[ 13 /*Enter*/, 'doNothing'],
[ CKEDITOR.ALT + 121 /*F10*/, 'toolbarFocus' ],
[ CKEDITOR.ALT + 122 /*F11*/, 'elementsPathFocus' ],
[ CKEDITOR.SHIFT + 121 /*F10*/, 'contextMenu' ],
[ CKEDITOR.CTRL + 90 /*Z*/, 'undo' ],
[ CKEDITOR.CTRL + 89 /*Y*/, 'redo' ],
[ CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 /*Z*/, 'redo' ],
[ CKEDITOR.CTRL + 76 /*L*/, 'link' ],
[ CKEDITOR.CTRL + 66 /*B*/, 'bold' ],
[ CKEDITOR.CTRL + 73 /*I*/, 'italic' ],
[ CKEDITOR.CTRL + 85 /*U*/, 'underline' ],
[ CKEDITOR.ALT + 109 /*-*/, 'toolbarCollapse' ]
];
Voila! Now the enter key does absolutely nothing. You should also be able assign 'doNothing' to any other key you want to disable, though I haven't tried others myself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With