title: Calculation on keypress event (or number only in keyup event)
body: <p>I try to calculate a discount and allowing numbers only in the discount field. When I use the keyup event, the calculation is right but I still can type any characters, if I use the keypress event, the restriction on characters works but the calculation does not work anymore (the first input is not recorded).</p>
  
  <p>Here is a codepen of my code : <a href="http://codepen.io/mbrillaud/pen/jEzBGy?editors=101" rel="nofollow">http://codepen.io/mbrillaud/pen/jEzBGy?editors=101</a></p>
  
  <pre><code>$(document).ready(function(){
      var $discount = $('#discount'),
          $price = $('#price'),
          $newPrice = $('#new-price');
  
  
      $discount.on('keypress', function(e) {
          if (e.which != 8 &amp;&amp; e.which != 0 &amp;&amp; (e.which &lt; 48 || e.which &gt; 57)){
              return false;
          }
      $newPrice.val(
          Math.round(
              ($price.val() - (($discount.val() / 100) * $price.val()))* 100) / 100
          );
      });
  });
  </code></pre>
  
  <p>I used an answer from stackoverflow to check the numbers.</p>
  
  <p>Thanks by advance for your help</p>