title: Trigger a button click on the Enter key in a text box misses its value
body: <p>I have </p>
  
  <h3>Html:</h3>
  
  <pre><code>&lt;form  action="" method="post"  id="contactForm"&gt;
      &lt;input id='inputbox' name="inputbox" type="text" /&gt;
      &lt;button type="button" id='search'&gt; search &lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <h3>JavaScript</h3>
  
  <pre><code>$(document).ready(function() {
      $("#inputbox").keyup(function(event){
          if(event.keyCode == 13){
              $("#search").click();
          }
      });
  
      $('#search').click(function(){
           var inputbox= $("#inputbox").val();  
          //stuff
      });
  });        
  </code></pre>
  
  <p><strong>inputbox</strong> value is nothing when I press enter, however if I click on button It works perfectly with same input value</p>
  
  <p>maybe making  <strong>inputbox</strong> global? </p>