title: Why keyup works but keydown does not work
body: <p>I have an input type=&quot;number&quot; where the min value is 1, the max is 10. I want to prevent inputting a value greater or less than max and min, so I use this script:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$('input[name=inputModal1]').keyup(function(){
  if($(this).val()&gt;10){
    $(this).val(10);
  }else if($(this).val()&lt;1){
    $(this).val(1);}
  });
  $('input[name=inputModal2]').keydown(function(){
  if($(this).val()&gt;10){
    $(this).val(10);
  }else if($(this).val()&lt;1){
    $(this).val(1);}
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;input type="number" name="inputModal1" min="1" max="10" value="1"&gt;
  &lt;input type="number" name="inputModal2" min="1" max="10" value="1"&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>In this kind the script works, but I want to use <code>keydown</code>, it prevents entering more or less than the maximum and minimum value, but <code>keyup</code> gives more or less typing if the user presses and holds the button. What could be the reason that <code>keydown</code> is not working? I can remove the value, make it more than 10, etc.</p>
  <p>Let me know if you need more information.</p>