title: Javascript - get value from textbox at every keypress
body: <p>I have a textbox and I want to use the data in it every time something is entered; letter by letter.</p>
  
  <p>What is happening is that when a value is entered, the Javascript is being executed <em>before</em> the value is actually put into the textbox, meaning that it always lags one character behind.</p>
  
  <pre><code>$(document).ready(
        function() {
            $('#test').keypress(
  
            function() {
              var value = document.getElementById('test').value;
              alert(value);
            });
        })
  
  &lt;input id="test" type="text"  /&gt;
  </code></pre>
  
  <p>Here's whats happening:</p>
  
  <pre><code>input alert
    w    ""
    e    "w"
    a    "we"
    l    "wea"
    t    "weal"
    h    "wealt"
  </code></pre>
  
  <p>Whereas I want it to happen dynamically; i.e. when I enter "w" I want the alert to contain "w" immediately after.</p>