|
|
To find the key pressed with keycode - Javascript
|
Views : 271
|
|
Tagged in : Javascript
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
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>
|
|
By raja, On - 2010-02-01 |
|
|
|