title: Run a function at the first keypress event on an input
body: <p>I have an <code>input</code> element with an <code>onkeypress</code> event that runs a function, <code>change()</code>. The problem is that the function doesn't run for the very first keypress. For example, I have to type <strong>55</strong> instead of <strong>5</strong> to get the function to update, and the value it takes is <strong>5</strong>. Somehow, it doesn't recognize the most recent keypress. I tried adding other events, such as <code>onfocus</code> and <code>onselect</code>, to no avail. Here is the code for the <code>input</code>:</p>
  
  <pre><code>&lt;input id="x" type="text" size="1" maxlength="2" onkeypress="change()" onfocus="change()" onselect="change()" onblur="change()" onchange="change()"&gt;&lt;/input&gt;
  </code></pre>
  
  <p><a href="http://jsfiddle.net/j8B8b/1/" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mr6FN.png" alt="JSFiddle"></a></p>