Currently, if the person presses enter inside the text area, the form will submit.
Good, I want that.
But when they type shift + enter, I want the textarea to move to the next line: \n
How can I do that in JQuery or plain JavaScript as simple as possible?
Better use simpler solution:
Tim’s solution below is better I suggest using that:
https://stackoverflow.com/a/6015906/4031815
My solution
I think you can do something like this..
EDIT : Changed the code to work irrespective of the caret postion
First part of the code is to get the caret position.
Ref: How to get the caret column (not pixels) position in a textarea, in characters, from the start?
And then replacing the textarea value accordingly when Shift + Enter together , submit the form if Enter is pressed alone.
Here is a demo