Menu Close

JQuery Keydown() Event With Example

Keydown event

In this example, we will learn about the jquery keydown() event. When we press the key on the keyboard, the jquery keydown() event occurs. It triggers the function associated with the event.

The keydown() event is divided into two event methods.

  1. Keypress(): This event specifies that the key is pressed down.
  2. Keyup(): This event specifies that the key is released.

The above syntax specifies the keydown event for selected elements and it executes the function when it triggers.


Follow the below example to create a jquery keydown() event.

<!DOCTYPE html>
<html lang="en">
    <title>JQuery keydown() event with example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src=""></script> 
    Enter your name: <input type="text">
                $("input").css("background-color", "#89CFF0");  
                $("input").css("background-color", "#FBCEB1");  
Posted in HTML, jQuery, Web Technologies

You can also read...