I thought this might be helpful for someone. I needed to provide a very basic editor just to allow bold, italics, and links. But the text was going to be formatted as a single line in a ul, so I needed to disable the enter key entirely. Rather than stripping out the <p> tags on submit, I created a plugin which registers a dummy command. Then I added the plugin and assigned the 'doNothing' command to the enter key:
Here is the plugin.js for my 'doNothing' plugin:
As you can see, it does nothing. It would be nice if some sort of null command like this were built in. If there is one, I couldn't find it.
config.extraPlugins = 'doNothing'; config.keystrokes = [[ 13 /*Enter*/, 'doNothing']];(Make sure to add back in any default keystrokes that you want as well.)
Here is the plugin.js for my 'doNothing' plugin:
(function() { var doNothingCmd = { exec : function( editor ) { return; } }; var pluginName = 'doNothing'; CKEDITOR.plugins.add( pluginName, { init : function( editor ) { editor.addCommand( pluginName, doNothingCmd ); } }); })();
As you can see, it does nothing. It would be nice if some sort of null command like this were built in. If there is one, I couldn't find it.
Re: Disable Enter Key
Re: Disable Enter Key
Probably. But the point of this is to disable the enter key for single line entries, and therefore lists are undesirable for the same reason.
Re: Disable Enter Key
Re: Disable Enter Key
Very useful! Normally when you have a form with several text input fields, it is undesirable that the form gets submitted when the user hits ENTER in a field. Some people are pressing the enter key instead of the tab key to get to the next field. They often do that by accident or because they are accustomed to terminate field input that way.
Its an old post, but thanks,
Its an old post, but thanks, just what I needed.
One minor enhancement to pass along: disable the shift-enter key which otherwise produces a <br>.
I'm using the jquery connector, here is my config:
Also the autoParagraph=false helps keep out the <p> and <br> tags, but pasted content still gets through. I still need to run it through a post-process to remove excess tags.