![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
jQuery event.which property
The event.which property in jQuery is used to return which keyboard key or mouse button was pressed for the event.
Syntax
The syntax is as follows −
event.which
Example
Let us now see an example to implement the jQuery event.which property −
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("input").keydown(function(event){ $("div").html("Which key pressed? = " + event.which); }); }); </script> </head> <body> <h2>Student Details</h2> Student Name: <input type="text"><br> Student Address: <input type="text"> <p><strong>Note:</strong> The key pressed in the any of the above input would be visible below.</p> <div /> </body> </html>
Output
This will produce the following output −
Let us now enter a value and press a key in the input −
Advertisements