- Trending Categories
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
How to check which key has been pressed using jQuery?
To check which key has been pressed, use the onkeydown attribute.
Example
You can try to run the following code to get which key is pressed:
<!DOCTYPE html> <html> <body> <p>Press a key in the below box to get which key is pressed.</p> <input type="text" size="10" onkeydown="demoFunction(event)"> <p id="test"></p> <script> function demoFunction(event) { var a = event.key; document.getElementById("test").innerHTML = "You've pressed the key: " + a; } </script> </body> </html>
- Related Articles
- How to know which key was pressed in a form input using jQuery?
- How to check if a "lateInit" variable has been initialized in Kotlin?
- JavaScript - Detecting the pressed arrow key
- How to find out what character key is pressed in JavaScript?
- How to check if an element has a class in jQuery?
- C++ Program to check if a string has been seen before
- How to check if an element has a certain class name with jQuery?
- Check whether Enter key is pressed or not and display the result in console with JavaScript?
- How to check if a div is visible using jQuery?
- How to Check Mentioned File Exists or not using JavaScript/jQuery?
- How to check an array is empty or not using jQuery?
- How to check the current selection against an expression using jQuery?
- How to check two elements are the same using jQuery/JavaScript?
- How to pause a pylab figure until a key is pressed or mouse is clicked? (Matplotlib)
- Python Pandas - Check whether the DateOffset value has been normalized or not

Advertisements