How To Capture Keyboard Events Using JQuery

By Ravindra T C Mar 24, 2012
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.

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

COMMENT USING

PREMIUM SPONSORS

Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.

Latest Blogs