Hai,
sorry for a long reply .. I am just cut pasting a source i had & hope it helps.
<html>
<head>
<title>KeyTrap Key-Detection
Test Page</title>
<script language="javascript">
<!-- start hide
// this script block contains code normally found in keytrap.js
function Key(ns4code, ns5code, ns6code,
ie4code, ie5code, ie6code, action, modkeys) {
this.ns4code = ns4code; // ns4 keycode value
this.ns5code = ns5code; // ns5 keycode value
this.ns6code = ns6code; // ns6 keycode value
this.ie4code = ie4code; // ie4 keycode value
this.ie5code = ie5code; // ie5 keycode value
this.ie5code = ie6code; // ie6 keycode value
this.action = eval(action); // method called on detection
// if the optional modkeys argument is not present in the call
// to new Key(), this.modkeys is set to "", meaning that no mod
// keys must be held down for this Key object to be detected
if (arguments.length == 8)
this.modkeys = modkeys;
else
this.modkeys = "";
}
var Keys = new Array(); // store Key objects in Keys[] array
var Count = 0; // index into Keys[]
var Ns4 = false; var Ns5 = false; var Ns6 = false; var Ns4up = false;
var Ie4 = false; var Ie5 = false; var Ie6 = false; var Ie4up = false;
// note the workaround to get Ns6
if (navigator.appName.indexOf("Netscape") != -1) {
if (navigator.userAgent.indexOf("Netscape6") != -1) Ns6 = true;
else if (parseInt(navigator.appVersion) >= 5) Ns5 = true;
else if (parseInt(navigator.appVersion) >= 4) Ns4 = true;
if (Ns4 | | Ns5 | | Ns6) Ns4up = true;
}
// and the workarounds to get Ie5 and Ie6
else if (navigator.appName.indexOf("Explorer") != -1) {
if (navigator.userAgent.indexOf("MSIE 6") != -1) Ie6 = true;
if (navigator.userAgent.indexOf("MSIE 5") != -1) Ie5 = true;
else if (parseInt(navigator.appVersion) >= 4) Ie4 = true;
if (Ie4 | | Ie5 | | Ie6) Ie4up = true;
}
// modifier-key processing globals
var Shift = false, Ctrl = false, Alt = false;
var SHIFT_KEYCODE = 16, CTRL_KEYCODE = 17, ALT_KEYCODE = 18;
function keyDown(evt) {
// begin by getting the keycode of the depressed key and all
// currently depressed modifier keys (Shift, Ctrl, Alt)
var keycode;
if (Ns4up) {
keycode = evt.which;
// Netscape Shift/Ctrl/Alt processing only in 5+ browsers
if (keycode == SHIFT_KEYCODE && (Ns5 | | Ns6)) Shift = true;
if (keycode == CTRL_KEYCODE && (Ns5 | | Ns6)) Ctrl = true;
if (keycode == ALT_KEYCODE && (Ns5 | | Ns6)) Alt = true;
}
else if (Ie4up) {
keycode = event.keyCode;
Shift = event.shiftKey;
Ctrl = event.ctrlKey;
Alt = event.altKey;
}
// execute the action associated with keycode and all the
// currently depressed modified keys (Shift, Ctrl, Alt)
for (var i=0; i<Keys.length; i++) {
if ((Ns4 && (keycode == Keys[i].ns4code)) | |
(Ns5 && (keycode == Keys[i].ns5code)) | |
(Ns6 && (keycode == Keys[i].ns6code)) | |
(Ie4 && (keycode == Keys[i].ie4code)) | |
(Ie5 && (keycode == Keys[i].ie5code)) | |
(Ie6 && (keycode == Keys[i].ie6code))) {
if ((Shift && (Keys[i].modkeys.toLowerCase().indexOf("shift") != -1) | |
!Shift && (Keys[i].modkeys.toLowerCase().indexOf("shift") == -1)) &&
(Ctrl && (Keys[i].modkeys.toLowerCase().indexOf("ctrl") != -1) | |
!Ctrl && (Keys[i].modkeys.toLowerCase().indexOf("ctrl") == -1)) &&
(Alt && (Keys[i].modkeys.toLowerCase().indexOf("alt") != -1) | |
!Alt && (Keys[i].modkeys.toLowerCase().indexOf("alt") == -1))) {
Keys[i].action();
return;
}
}
}
}
document.onkeydown = keyDown;
if (Ns4up) document.captureEvents(Event.KEYDOWN);
// end hide -->
</script>
<script language="javascript">
<!-- start hide
// display detected key in keynameText text box
function show(str) {
document.forms[0].keynameText.value = str;
window.focus();
}
/* control keys ***************************************** */
// Backspace key
Keys[Count++] = new Key(8, 8, 8, 8, 8, 8, "bs");
function bs() { show("backspace"); }
// Tab key
Keys[Count++] = new Key(-1, 9, 9, 9, 9, 9, "tab");
function tab() { show("tab"); }
// Enter key
Keys[Count++] = new Key(13, 13, 13, 13, 13, 13, "enter");
function enter() { show("enter"); }
// Esc key
Keys[Count++] = new Key(-1, 27, 27, 27, 27, 27, "esc");
function esc() { show("esc"); }
// Spacebar key
Keys[Count++] = new Key(32, 32, 32, 32, 32, 32, "sb");
function sb() { show("spacebar"); }
// Left Arrow key
Keys[Count++] = new Key(-1, 37, 37, 37, 37, 37, "la");
function la() { show("left arrow"); }
// Up Arrow key
Keys[Count++] = new Key(1, 38, 38, 38, 38, 38, "ua");
function ua() { show("up arrow"); }
// Right Arrow key
Keys[Count++] = new Key(-1, 39, 39, 39, 39, 39, "ra");
function ra() { show("right arrow"); }
// Down Arrow key
Keys[Count++] = new Key(-1, 40, 40, 40, 40, 40, "da");
function da() { show("down arrow"); }
/* function keys **************************************** */
// F1 key
Keys[Count++] = new Key(-1, 112, 112, 112, 112, 112, "f1");
function f1() { show("f1"); }
// F2 key
Keys[Count++] = new Key(-1, 113, 113, 113, 113, 113, "f2");
function f2() { show("f2"); }
// F3 key
Keys[Count++] = new Key(-1, 114, 114, 114, 114, 114, "f3");
function f3() { show("f3"); }
// F4 key
Keys[Count++] = new Key(-1, 115, 115, 115, 115, 115, "f4");
function f4() { show("f4"); }
// F5 key
Keys[Count++] = new Key(-1, 116, 116, 116, 116, 116, "f5");
function f5() { show("f5"); }
// F6 key
Keys[Count++] = new Key(-1, 117, 117, 117, 117, 117, "f6");
function f6() { show("f6"); }
// F7 key
Keys[Count++] = new Key(-1, 118, 118, 118, 118, 118, "f7");
function f7() { show("f7"); }
// F8 key
Keys[Count++] = new Key(-1, 119, 119, 119, 119, 119, "f8");
function f8() { show("f8"); }
// F9 key
Keys[Count++] = new Key(-1, 120, 120, 120, 120, 120, "f9");
function f9() { show("f9"); }
// F10 key
Keys[Count++] = new Key(-1, 121, 121, 121, 121, 121, "f10");
function f10() { show("f10"); }
// F11 key
Keys[Count++] = new Key(-1, 122, 122, 122, 122, 122, "f11");
function f11() { show("f11"); }
// F12 key
Keys[Count++] = new Key(-1, 123, 123, 123, 123, 123, "f12");
function f12() { show("f12"); }
/* letter keys ****************************************** */
// A key
Keys[Count++] = new Key(97, 65, 65, 65, 65, 65, "a");
function a() { show("a"); }
// B key
Keys[Count++] = new Key(98, 66, 66, 66, 66, 66, "b");
function b() { show("b"); }
// C key
Keys[Count++] = new Key(99, 67, 67, 67, 67, 67, "c");
function c() { show("c"); }
// D key
Keys[Count++] = new Key(100, 68, 68, 68, 68, 68, "d");
function d() { show("d"); }
// E key
Keys[Count++] = new Key(101, 69, 69, 69, 69, 69, "e");
function e() { show("e"); }
// F key
Keys[Count++] = new Key(102, 70, 70, 70, 70, 70, "f");
function f() { show("f"); }
// G key
Keys[Count++] = new Key(103, 71, 71, 71, 71, 71, "g");
function g() { show("g"); }
// H key
Keys[Count++] = new Key(104, 72, 72, 72, 72, 72, "h");
function h() { show("h"); }
// I key
Keys[Count++] = new Key(105, 73, 73, 73, 73, 73, "i");
function i() { show("i"); }
// J key
Keys[Count++] = new Key(106, 74, 74, 74, 74, 74, "j");
function j() { show("j"); }
// K key
Keys[Count++] = new Key(107, 75, 75, 75, 75, 75, "k");
function k() { show("k"); }
// L key
Keys[Count++] = new Key(108, 76, 76, 76, 76, 76, "l");
function l() { show("l"); }
// M key
Keys[Count++] = new Key(109, 77, 77, 77, 77, 77, "m");
function m() { show("m"); }
// N key
Keys[Count++] = new Key(110, 78, 78, 78, 78, 78, "n");
function n() { show("n"); }
// O key
Keys[Count++] = new Key(111, 79, 79, 79, 79, 79, "o");
function o() { show("o"); }
// P key
Keys[Count++] = new Key(113, 80, 80, 80, 80, 80, "p");
function p() { show("p"); }
// Q key
Keys[Count++] = new Key(113, 81, 81, 81, 81, 81, "q");
function q() { show("q"); }
// R key
Keys[Count++] = new Key(114, 82, 82, 82, 82, 82, "r");
function r() { show("r"); }
// S key
Keys[Count++] = new Key(115, 83, 83, 83, 83, 83, "s");
function s() { show("s"); }
// T key
Keys[Count++] = new Key(116, 84, 84, 84, 84, 84, "t");
function t() { show("t"); }
// U key
Keys[Count++] = new Key(117, 85, 85, 85, 85, 85, "u");
function u() { show("u"); }
// V key
Keys[Count++] = new Key(118, 86, 86, 86, 86, 86, "v");
function v() { show("v"); }
// W key
Keys[Count++] = new Key(119, 87, 87, 87, 87, 87, "w");
function w() { show("w"); }
// X key
Keys[Count++] = new Key(120, 88, 88, 88, 88, 88, "x");
function x() { show("x"); }
// Y key
Keys[Count++] = new Key(121, 89, 89, 89, 89, 89, "y");
function y() { show("y"); }
// Z key
Keys[Count++] = new Key(122, 90, 90, 90, 90, 90, "z");
function z() { show("z"); }
/* number keys ****************************************** */
// 0 key
Keys[Count++] = new Key(48, 48, 48, 48, 48, 48, "_0");
function _0() { show("0"); }
// 1 key
Keys[Count++] = new Key(49, 49, 49, 49, 49, 49, "_1");
function _1() { show("1"); }
// 2 key
Keys[Count++] = new Key(50, 50, 50, 50, 50, 50, "_2");
function _2() { show("2"); }
// 3 key
Keys[Count++] = new Key(51, 51, 51, 51, 51, 51, "_3");
function _3() { show("3"); }
// 4 key
Keys[Count++] = new Key(52, 52, 52, 52, 52, 52, "_4");
function _4() { show("4"); }
// 5 key
Keys[Count++] = new Key(53, 53, 53, 53, 53, 53, "_5");
function _5() { show("5"); }
// 6 key
Keys[Count++] = new Key(54, 54, 54, 54, 54, 54, "_6");
function _6() { show("6"); }
// 7 key
Keys[Count++] = new Key(55, 55, 55, 55, 55, 55, "_7");
function _7() { show("7"); }
// 8 key
Keys[Count++] = new Key(56, 56, 56, 56, 56, 56, "_8");
function _8() { show("8"); }
// 9 key
Keys[Count++] = new Key(57, 57, 57, 57, 57, 57, "_9");
function _9() { show("9"); }
/* punctuation keys ************************************* */
// ` key
Keys[Count++] = new Key(96, 192, 192, 192, 192, 192, "backap");
function backap() { show("`"); }
// - key
Keys[Count++] = new Key(45, 109, 109, 189, 189, 189,"dash");
function dash() { show("-"); }
// = key
Keys[Count++] = new Key(61, 61, 61, 187, 187, 187, "equals");
function equals() { show("="); }
// \ key
Keys[Count++] = new Key(92, 220, 220, 220, 220, 220, "backslash");
function backslash() { show("\\"); }
// [ key
Keys[Count++] = new Key(91, 219, 219, 219, 219, 219, "leftbr");
function leftbr() { show("["); }
// ] key
Keys[Count++] = new Key(93, 221, 221, 221, 221, 221, "rightbr");
function rightbr() { show("]"); }
// ; key
Keys[Count++] = new Key(59, 59, 59, 186, 186, 186, "semicolon");
function semicolon() { show(";"); }
// ' key
Keys[Count++] = new Key(39, 222, 222, 222, 222, 222, "ap");
function ap() { show("'"); }
// , key
Keys[Count++] = new Key(44, 188, 188, 188, 188, 188, "comma");
function comma() { show(","); }
// . key
Keys[Count++] = new Key(46, 190, 190, 190, 190, 190, "period");
function period() { show("."); }
// / key
Keys[Count++] = new Key(47, 191, 191, 191, 191, 191, "forwardslash");
function forwardslash() { show("/"); }
/* combination keys ************************************* */
// Shift+Enter key
Keys[Count++] = new Key(13, 13, 13, 13, 13, 13, "shenter", "shift");
function shenter() { show("shift+enter"); }
// Ctrl+Enter key
Keys[Count++] = new Key(13, 13, 13, 13, 13, 13, "ctenter", "ctrl");
function ctenter() { show("ctrl+enter"); }
// Alt+Enter key
Keys[Count++] = new Key(13, 13, 13, 13, 13, 13, "alenter", "alt");
function alenter() { show("alt+enter"); }
// Shift+Ctrl+Enter key
Keys[Count++] = new Key(13, 13, 13, 13, 13, 13, "shctenter", "shift+ctrl");
function shctenter() { show("shift+ctrl+enter"); }
// Ctrl+Alt+Enter key
Keys[Count++] = new Key(13, 13, 13, 13, 13, 13, "ctalenter", "ctrl+alt");
function ctalenter() { show("ctrl+alt+enter"); }
// Shift+Ctrl+Alt+Enter key
Keys[Count++] = new Key(13, 13, 13, 13, 13, 13, "shctalenter", "shift+ctrl+alt");
function shctalenter() { show("shift+ctrl+alt+enter"); }
// Shift+g key
Keys[Count++] = new Key(71, 71, 71, 71, 71, 71, "shg", "shift");
function shg() { show("shift+g"); }
// Ctrl+g key
Keys[Count++] = new Key(71, 71, 71, 71, 71, 71, "ctg", "ctrl");
function ctg() { show("ctrl+g"); }
// Alt+g key
Keys[Count++] = new Key(71, 71, 71, 71, 71, 71, "alg", "alt");
function alg() { show("alt+g"); }
// Shift+Ctrl+g key
Keys[Count++] = new Key(71, 71, 71, 71, 71, 71, "shctg", "shift+ctrl");
function shctg() { show("shift+ctrl+g"); }
// Ctrl+Alt+g key
Keys[Count++] = new Key(71, 71, 71, 71, 71, 71, "ctalg", "ctrl+alt");
function ctalg() { show("ctrl+alt+g"); }
// Shift+Ctrl+Alt+g key
Keys[Count++] = new Key(71, 71, 71, 71, 71, 71, "shctalg", "shift+ctrl+alt");
function shctalg() { show("shift+ctrl+alt+g"); }
// Shift+UpArrow key
Keys[Count++] = new Key(38, 38, 38, 38, 38, 38, "shup", "shift");
function shup() { show("shift+up arrow"); }
// Ctrl+UpArrow key
Keys[Count++] = new Key(38, 38, 38, 38, 38, 38, "ctup", "ctrl");
function ctup() { show("ctrl+up arrow"); }
// Alt+UpArrow key
Keys[Count++] = new Key(38, 38, 38, 38, 38, 38, "alup", "alt");
function alup() { show("alt+up arrow"); }
// Shift+Ctrl+UpArrow key
Keys[Count++] = new Key(38, 38, 38, 38, 38, 38, "shctup", "shift+ctrl");
function shctup() { show("shift+ctrl+up arrow"); }
// Ctrl+Alt+UpArrow key
Keys[Count++] = new Key(38, 38, 38, 38, 38, 38, "ctalup", "ctrl+alt");
function ctalup() { show("ctrl+alt+up arrow"); }
// Shift+Ctrl+Alt+UpArrow key
Keys[Count++] = new Key(38, 38, 38, 38, 38, 38, "shctalup", "shift+ctrl+alt");
function shctalup() { show("shift+ctrl+alt+up arrow"); }
// Shift+F2 key
Keys[Count++] = new Key(113, 113, 113, 113, 113, 113, "shf2", "shift");
function shf2() { show("shift+f2"); }
// Ctrl+F2 key
Keys[Count++] = new Key(113, 113, 113, 113, 113, 113, "ctf2", "ctrl");
function ctf2() { show("ctrl+f2"); }
// Alt+F2 key
Keys[Count++] = new Key(113, 113, 113, 113, 113, 113, "alf2", "alt");
function alf2() { show("alt+f2"); }
// Shift+Ctrl+F2 key
Keys[Count++] = new Key(113, 113, 113, 113, 113, 113, "shctf2", "shift+ctrl");
function shctf2() { show("shift+ctrl+f2"); }
// Ctrl+Alt+F2 key
Keys[Count++] = new Key(113, 113, 113, 113, 113, 113, "ctalf2", "ctrl+alt");
function ctalf2() { show("ctrl+alt+f2"); }
// Shift+Ctrl+Alt+F2 key
Keys[Count++] = new Key(113, 113, 113, 113, 113, 113, "shctalf2", "shift+ctrl+alt");
function shctalf2() { show("shift+ctrl+alt+f2"); }
// end hide -->
</script>
</head>
<body>
<H1>KeyTrap Key-Detection Test Page</H1>
Thank you for testing KeyTrap. :-) Your results will help make KeyTrap.js a truly "browser-universal" key-detection library. Please post your results to the <a href="http://f5.dejanews.com/frameset/frameset.cgi?channel=devhead&forum=scripthead">ScriptHead Forum.</a><p>
<form>
You pressed: <input type="text" name="keynameText" onFocus="this.blur()"><p>
1. In Netscape 4+ or MSIE 4+, press each of the following keys. Except where noted, the pressed key's identity should be displayed in the above text box. If not, please let me know.<p>
<table border="2" cellspacing="0" cellpadding="4" bgcolor="#99CCFF">
<tr>
<td>
<p>Note: In some cases, your browser and/or operating system might trap a key (in step 1) or a key combination (in step 2) *before* KeyTrap gets around to it. If this happens, please include it in your results.</p>
</td>
</tr>
</table><p>
<ul>
<li>All alphanumeric/punctuation keys, but *not* in combination with Shift, Ctrl, or Alt (and their Mac equivalents)<br>
<li>Esc (won't work in NS4), Tab (ditto), Backspace, Spacebar, and Enter<br>
<li>All twelve function keys (won't work in NS4)<br>
<li>The four arrow keys (won't work in NS4)
</ul><p>
2. Press each of the following key combinations (alas, these will not work in NS4, because NS4 does not support Shift/Ctrl/Alt+key detection). Again, please let me know if any of these combos' identities is not displayed in the text box.<p>
<ul>
<li>Shift+Enter, Ctrl+Enter, Alt+Enter, Shift+Ctrl+Enter, Ctrl+Alt+Enter, Shift+Ctrl+Alt+Enter<br>
<li>Shift+g, Ctrl+g, Alt+g, Shift+Ctrl+g, Ctrl+Alt+g, Shift+Ctrl+Alt+g<br>
<li>Shift+UpArrow, Ctrl+UpArrow, Alt+UpArrow, Shift+Ctrl+UpArrow, Ctrl+Alt+UpArrow, Shift+Ctrl+Alt+UpArrow<br>
<li>Shift+F2, Ctrl+F2, Alt+F2, Shift+Ctrl+F2, Ctrl+Alt+F2, Shift+Ctrl+Alt+F2<br>
</ul>
</FORM>
</body>
</html>
Regards,
srini