How To Capture Keyboard Events Using JQuery

In this article I will discuss how to capture keyboard events using Jquery. This will help us to know the values of each keystroke in the keyboard. Just follow the simple steps to write Jquery function.

Steps to follow:

1.  In HTML page add the following JS file in between head tags(<head></head>)

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>

2. After this add the following Javascript function next to that reference file.

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
script type="text/javascript" language="javascript">
$(document).ready(function () {
$(document).live('keydown', function (e) {
alert('The key value is : ' + e.which);
});
});

</
script>

3. Then Run your HTML page in browser and hit “ENTER” key you will get the result.

img1.gif

Ebook Download
View all
Learn
View all