Saturday, May 19, 2007

JavaScript Get Key Values Or Code On KeyDown

Script
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Find KeyCode</title>
<script language="JavaScript">
function TriggeredKey(e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
alert("keycode: " + keycode);
}
</script>
</head>
<body onkeydown="TriggeredKey(this)">
</body>
</html>




(IE Supported)


Special Keyboard Key(s) Code

KeyCode
Backspace      8
Tab           9
Enter        13
Shift        16
Ctrl         17
Alt          18
Pause/Break   19
Caps Lock     20
Esc          27
Page Up      33
Page Down     34
End          35
Home         36
Left Arrow    37
Print Screen 44
Delete       46
F1           112
F2           113
F3           114
F4           115
F5           116
F6           117
F7           118
F8           119
F9           120
F10          121
F11          122
F12          123


No comments:

Creative Commons License
Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.