title: jquery keypress() event get text
body: <p>I want a function to be run when a keypress occurs on a text box, so I have this code:</p>
  
  <pre><code>$("input[x]").keypress(function() {
          DoX();
      })
  </code></pre>
  
  <p>This is working fine, but in my function I want to do something based on the text value in the textbox</p>
  
  <pre><code>var textValue = ("input[x]").val();
  </code></pre>
  
  <p>Now the problem here is that it lags behind by a key so if my text box says 'He' and I type an 'l', then I want my textValue to be 'Hel', but it is returning the previous value 'He' because presumably the character hasn't been put in the text box yet.</p>
  
  <p>Is there a way of getting 'Hel' out of my function here?</p>
  
  <p>Thanks :)</p>