To find the key pressed with keycode

by raja 2010-02-01 14:10:31

The following code will alert the key pressed with keycode.


<script type="text/javascript">
function doSomething(e) {
var code;
if (!e) var e = window.event;
if (e.keyCode) code = e.keyCode;
else if (e.which) code = e.which;
var character = String.fromCharCode(code);
alert('Character of ' + code+' is '+character);
}
document.onkeydown = doSomething;
</script>

Tagged in:

915
like
0
dislike
0
mail
flag

You must LOGIN to add comments