Api jQuery Keydown Event | By Example

jQuery keydown

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.



This triggers the keydown event for the selected elements.


Parameters of jQuery keydown()

FunctionIt is an optional parameter. It is executed itself when the keydown event is triggered.

Example of jQuery keydown()

Let’s see an example with demonstrate jQuery keydown().

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

In this jquery keydown event, set the background color “red” of an <input> field when a keyboard key is pressed down.

Spread the love

Be First to Comment

Leave a Reply

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