Keydown Event

<input type="text" id="keyInput" placeholder="Type here">
<p id="keyOutput"></p>

<script>
$(document).ready(function(){
  $("#keyInput").keydown(function(event){
$("#keyOutput").text("You pressed: " + event.key);
}); }); </script>

.keydown() fires whenever a key is pressed down.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *