jQuery keydown event method; Through this tutorial, i am going to show you what is jQuery keydown event and how to use jQuery keydown event with example.
jQuery Keydown Event Example
The Jquery keydown event happens when a keyboard key is pressed down. When you press a key on the keyboard, the keydown () event occurs and once the keydown () event occurs, it executes the function associated with the keydown () method to run.
Syntax jQuery Keydown Event Method
$(selector).keydown()
This triggers the keydown event for the selected elements.
$(selector).keydown(function)
Parameters of jQuery Keydown Event Method
Parameter | Description |
---|---|
Function | It is an optional parameter. It is executed itself when the keydown event is triggered. |
Example jQuery Keydown Event Method
<!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> <script> $(document).ready(function(){ $("input").keydown(function(){ $("input").css("background-color", "red"); }); }); </script> </head> <body> Write something: <input type="text"> </body> </html>
Demo Query Keydown Event Method
Write something:
Recommended jQuery Tutorial
Recommended:-How to Get Element by class, name, id in jQuery
Recommended:-jQuery Events List with Example
Recommended:-jQuery Click() Event Example
Recommended:-jQuery Blur Event Method Example
Recommended:-jQuery Focus () Event Method Example
Recommended:-jQuery Toggle Show Hide div on Click
Recommended:-jQuery Select Event Method
Recommended:-jQuery Get Selected Dropdown Option Value onchange