title: How might I implement immediate text submission when the enter key is pressed in a textarea?
body: <h3>Duplicate:</h3>
  <blockquote>
  <p><a href="https://stackoverflow.com/questions/789701/submitting-data-from-textarea-by-hitting-enter">Submitting data from textarea by hitting “Enter”.</a></p>
  </blockquote>
  <hr />
  <p>I've got a textarea and a submit button:</p>
  <pre><code>&lt;textarea id=&quot;chat&quot;&gt;&lt;/textarea&gt;
  &lt;input type=&quot;submit&quot; value=&quot;Submit&quot; onclick=&quot;send_msg();&quot;&gt;
  </code></pre>
  <p>The value of the of the texarea is submitted when Enter is hit:</p>
  <pre><code>    textarea.onkeyup = function(e) {
          alert(e.keyCode);
          e = e || window.event;
          if (e.keyCode === 13) {
              send_msg();
          }
          return true;
      }
  </code></pre>
  <p>Problem is to make the textarea submit its value prior to letting the cursor to jump to the next line. How's it possible to do that?</p>