title: How to submit a form when the Enter Key on a textarea?
body: <p>I want to submit the content in the textarea as shown below by just hitting the <code>Enter</code> key on any keyboard on planet earth. When the user hits the <code>Shift+Enter</code> key, the caret has to go to a new line and on hitting <code>Enter</code> the submitted textarea content should have the new lines created when the <code>Shift+Enter</code> was pressed. The content of the textarea should be inserted after the the div with class <code>commentWrap</code> but the last submitted comment should apear last and vice verser. </p>
  
  <p>I want this solution to work in all browsers. </p>
  
  <pre><code>&lt;div class="commentWrap"&gt;&lt;/div&gt;
  
  &lt;textarea id="test"&gt;&lt;/textarea&gt;
  
  &lt;script type="text/javascript"&gt;
      $(document).ready(function() {
          $("#test").keypress(function(e) {
              var textVal = $(this).val();
              if(e.which == 13 &amp;&amp; e.shiftKey) {
                  //What should I really do here
              }
              else if (e.which == 13 &amp;&amp; ! e.shiftKey) {
                  e.preventDefault(); //Stops enter from creating a new line
                  //this.form.submit(); //or ajax submit
                  if (this.value ==="") {
                      alert("Hey punk! Put some text before you hit enter.");
                  }else {
                      alert(textVal);
                      $("&lt;div class='comment'&gt;"+ textVal +"&lt;/div&gt;").insertAfter('.commentWrap');
                  }
              }
          });
      });
  &lt;/script&gt;
  </code></pre>