title: Update input in real-time with jQuery
body: <p>I'm creating a script for percentage calculation on my e-commerce, but I have a problem. </p>
  
  <p>I want price update in real time as I write the percentage in the field.</p>
  
  <p>So I made this:</p>
  
  <pre><code>&lt;input type="text" name="cost" onchange="disc()"&gt;
  
  &lt;input type="text" name="discount" id="prized" onchange="updateInput()"&gt;
  
  &lt;input type="text" name="price" value=""&gt;
  
  &lt;script&gt;
  function updateInput(){
  
    var discount = document.getElementsByName("discount")[0].value;
    var cost = document.getElementsByName("cost")[0].value;
    document.getElementsByName("price")[0].value = cost - (cost * (discount / 100)); 
  
  }
  
  function disc(){
  
      if($("#prized").val().length &gt; 1) {
  
          var discount = document.getElementsByName("discount")[0].value;
          var cost = document.getElementsByName("cost")[0].value;
          document.getElementsByName("price")[0].value = cost - (cost * (discount / 100));
  
      }
  }
  &lt;script&gt;
  </code></pre>
  
  <p>But it does not work as I would like...</p>
  
  <p>It does not update in real time, for "onchange".</p>
  
  <p>So I did some research, and I found an interesting function: <code>.keydown()</code></p>
  
  <p>I have no idea how to use it in my script.</p>
  
  <p>Someone can help me reach my goal?</p>