title: submit form with enter key that has button in it
body: <p>I need to submit the form with the enter key, but it is not like the other questions in this website in my case. I do not have a <code>input[type="submit"]</code>, but I have a button (<code>&lt;button id=""&gt;&lt;/button&gt;</code>).</p>
  
  <p>The full code of my form:</p>
  
  <pre><code>&lt;script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt;
  &lt;script src="js/my_script.js" type="text/javascript"&gt;&lt;/script&gt;
  
  &lt;form id="myForm" action="userInfo.php" method="post"&gt;
  &lt;textarea name="mesazhi" cols="35" rows="4"&gt;&lt;/textarea&gt;
  &lt;?php $idiperdoruesit = $_SESSION['id']; ?&gt;
  &lt;input type="hidden" name="idiperdoruesit" value="&lt;?php echo $idiperdoruesit; ?&gt;" /&gt;
  &lt;br /&gt;&lt;button id="sub" style="border-radius:0px; border-size:2px; border-style:solid; border-color:#ffffff; border-width:thin; background-color:#000000; color:#ffffff; height:26px; width:60px;  font-size:16px;"&gt;Send&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>When the user clicks the button Send, then a jquery function sends the message to the database without reloading the page. Below is the jquery function:</p>
  
  <pre><code>$("#sub").click( function() {
   $.post( $("#myForm").attr("action"), 
           $("#myForm :input").serializeArray(), 
           function(info){ $("#result").html(info); 
     });
   clearInput();
  });
  
  $("#myForm").submit( function() {
    return false; 
  });
  
  function clearInput() {
      $("#myForm :input").each( function() {
         $(this).val('');
      });
  }
  </code></pre>
  
  <p>How can I make to send the message by pressing the enter key?</p>