I am using jquery rich text editor jwysiwyg , i am able to submit the content on pressing enter key, by adding line
if(event.keyCode == 13) {
jQuery('#submit_button_id').focus().click();
}
in function $(this.editorDoc).keyup(function (event)
Problem now is shift+ENTER key also submit the value , cursor is not going to new line. Is there any way such that on pressing shift+ENTER goes to new line.
Thanks in advance.
I think you'll have to store whether shift is down in a variable. So in keydown you'll have (in pseudocode):
if(event.keyCode === KEYCODE_SHIFT) shiftDown = true;
and in keyup the opposite
if(event.keyCode === KEYCODE_SHIFT) shiftDown = false;
and then in keyup check:
if(event.keyCode === 13 && !shiftDown) {
...
EDIT
Actually, you can probably just use the event.shiftKey
property:
if(!event.shiftKey && event.keyCode === 13) {
...