
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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>
Advertisements