Loading ...

How to find which key was pressed | CodeAsp.Net

How to find which key was pressed

 /5
0 (0votes)

In this blog I will explain how to find which key was pressed with jQuery.I have used one textbox to explain that .On pressing any key an alert window will open and displays the key code of that key which was pressed. Below is the code:

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title></title>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

</head>

<body>

<div>

<input id="TestTextBox" type="text" />

</div>

</body>

<script type="text/javascript">

$(function()

{

$('#TestTextBox').keypress(function(e)

{

var code = null;

code = (e.keyCode ? e.keyCode : e.which);

alert('Key Code:' + code);

});

});

</script>

</html>

 

 

 

Happy Reading!

 

Comments (no comments yet)

Top Posts