jQuery keydown()

The jQuery keydown() method is used to attach a function to run when a keydown event occurs i.e, when a key is pressed on the keyboard.


To trigger the keydown event for selected elements.


To add a function to the keydown event.



  • It is an optional parameter.
  • The function parameter specifies the function to run when the event occurs.


Example 1

<!DOCTYPE html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    	$("input").css("background-color", "turquoise");  
    	$("input").css("background-color", "red");  
Write something: <input type="text">  

Try it

JS Bin on jsbin.com

Content Protection by DMCA.com
Please Share