Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, pressing <kbd>Enter</kbd> inside a textarea does not submit the form unless you have script to make it do that. That's the behaviour the user expects and I'd recommend against changing it. However, if you must do this, the easiest approach would be to find the script that is making <kbd>Enter</kbd> submit the form and change it. The code will have something like</p> <pre><code>if (evt.keyCode == 13) { form.submit(); } </code></pre> <p>... and you could just change it to </p> <pre><code>if (evt.keyCode == 13 &amp;&amp; !evt.shiftKey) { form.submit(); } </code></pre> <p>If you don't have access to this code for some reason, you need to do the following to make it work in all major browsers even if the caret is not at the end of the text:</p> <p>jsFiddle: <a href="http://jsfiddle.net/zd3gA/1/">http://jsfiddle.net/zd3gA/1/</a></p> <p>Code:</p> <pre><code>function pasteIntoInput(el, text) { el.focus(); if (typeof el.selectionStart == "number" &amp;&amp; typeof el.selectionEnd == "number") { var val = el.value; var selStart = el.selectionStart; el.value = val.slice(0, selStart) + text + val.slice(el.selectionEnd); el.selectionEnd = el.selectionStart = selStart + text.length; } else if (typeof document.selection != "undefined") { var textRange = document.selection.createRange(); textRange.text = text; textRange.collapse(false); textRange.select(); } } function handleEnter(evt) { if (evt.keyCode == 13 &amp;&amp; evt.shiftKey) { if (evt.type == "keypress") { pasteIntoInput(this, "\n"); } evt.preventDefault(); } } // Handle both keydown and keypress for Opera, which only allows default // key action to be suppressed in keypress $("#your_textarea_id").keydown(handleEnter).keypress(handleEnter); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload