Introduction:

Here we are going to explain what is keydown() event or how to use keydown() event or why to use keydown() event with example.

Description: 

In Jquery keydown event occurs when a keyboard key is pressed down, the keydown() event is occurred and once the keydown() event is occurred, it executes the function associated with keydown() method to run.

  • Syntax:

Trigger the keydown event for the selected elements:

 

$(selector).keydown()


  • Example of jQuery keydown() event


Let's see an example to of jQuery keydown() event.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AngularJS.aspx.cs"
Inherits="AngularJSTutorials.AngularJS" %>
 
<!DOCTYPE html>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.8.2.min.js"></script>   
  <script type="text/javascript">     
      $(document).ready(function () {
          $("input").keydown(function () {
              $("#content").text($(this).val());
              $("#content").css("color", "red");
          });
         
      });
 </script>
</head>
<body>
    <form id="form1" runat="server">
     Write something: <input type="text"> 
    <p id="content" style="margin-top:10px; width: 300px; height: 88px; color:#fff;">            
    </p> 
    </form>
</body>
</html>


Output:



I hope it will help to you.

0 comments


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

Welcome to SQL Tutorials Point

Don't have an account? Click here to Create a new account, it takes less than a minute.