Article

Introduction

https://cdn.jsdelivr.net/npm/[email protected]/dist/js.cookie.min.js
Copy to clipboard

The keydown() function is used when a key is pressed down but not release and a keyup() function is used when a pressed key is release.

Keyup() and keydown() are used to offer more control of keyboard presses than the normal keypress() function.

The following example shows how to use keydown() function: https://raw.githubusercontent.com/finsweet/jqueryCourse/main/jquery%20events/ex47.js?actionable=true We can use the on() function to replicate the above code: https://raw.githubusercontent.com/finsweet/jqueryCourse/main/jquery%20events/ex48.js?actionable=true

<script>
$(document).ready(function(){
  XT1
});
</script>
Copy to clipboard
Send to Live Demo

Live demo

<div id="minidivpage" class="example-live"><div id="message" class="box">This is some text inside of a div block.</div><div class="w-form"><form id="email-form" name="email-form" data-name="Email Form" method="get" aria-label="Email Form"><textarea placeholder="Example Text" maxlength="5000" id="field" name="field-2" data-name="Field 2" class="w-input"></textarea></form><div class="w-form-done" tabindex="-1" role="region" aria-label="Email Form success"><div>Thank you! Your submission has been received!</div></div><div class="w-form-fail" tabindex="-1" role="region" aria-label="Email Form failure"><div>Oops! Something went wrong while submitting the form.</div></div></div><div style="display:none;" id="hiddenMessage" class="box">This is a hidden message.</div></div>

<script>    
$(document).ready(function() {
  XT1
});
</script>
<script>
  
</script>
Copy to clipboard
Press the Run Demo button to execute the scripts above.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Your browser is too small

Resize your browser to be at least 769px wide.