title: How to submit form with enter key when I have a button, not a submit
body: <p>I have a form with a button submit type, and I would like it to submit when enter key is pressed. I don't know how to implement this with the JS function I call when submitting the form.</p>
  
  <p>FORM:</p>
  
  <pre><code>&lt;form name="form1"&gt;
  &lt;textarea name="msg" id="message"&gt;
  &lt;/textarea&gt;
  &lt;p id="button"&gt;
  &lt;input type="button" value="Enter" onclick="submitChat()" id="innerbutton"&gt;&lt;/p&gt;   
  </code></pre>
  
  <p>JS Function</p>
  
  <pre><code> function submitChat() {
  
  
      var uname = document.getElementById('nameplace').innerHTML
  
      var msg = form1.msg.value;
      var xmlhttp = new XMLHttpRequest();
  
      var badname = uname.charAt(0); 
  
      if (msg != "" &amp; badname != "&lt;") {
      xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState==4&amp;&amp;xmlhttp.status==200) {
      document.getElementById('chatlogs').innerHTML = xmlhttp.responseText;
              }
  
      }
      xmlhttp.open('GET','insert.php?uname='+uname+'&amp;msg='+msg,true);
      xmlhttp.send();
  
      }
  </code></pre>