keycode 8 = BackSpace BackSpace
keycode 9 = Tab Tabkeycode 12 = Clearkeycode 13 = Enterkeycode 16 = Shift_Lkeycode 17 = Control_Lkeycode 18 = Alt_Lkeycode 19 = Pausekeycode 20 = Caps_Lockkeycode 27 = Escape Escapekeycode 32 = space spacekeycode 33 = Priorkeycode 34 = Nextkeycode 35 = Endkeycode 36 = Homekeycode 37 = Leftkeycode 38 = Upkeycode 39 = Rightkeycode 40 = Downkeycode 41 = Selectkeycode 42 = Printkeycode 43 = Executekeycode 45 = Insertkeycode 46 = Deletekeycode 47 = Helpkeycode 48 = 0 equal bracerightkeycode 49 = 1 exclam onesuperiorkeycode 50 = 2 quotedbl twosuperiorkeycode 51 = 3 section threesuperiorkeycode 52 = 4 dollarkeycode 53 = 5 percentkeycode 54 = 6 ampersandkeycode 55 = 7 slash braceleftkeycode 56 = 8 parenleft bracketleftkeycode 57 = 9 parenright bracketrightkeycode 65 = a Akeycode 66 = b Bkeycode 67 = c Ckeycode 68 = d Dkeycode 69 = e E EuroSignkeycode 70 = f Fkeycode 71 = g Gkeycode 72 = h Hkeycode 73 = i Ikeycode 74 = j Jkeycode 75 = k Kkeycode 76 = l Lkeycode 77 = m M mukeycode 78 = n Nkeycode 79 = o Okeycode 80 = p Pkeycode 81 = q Q atkeycode 82 = r Rkeycode 83 = s Skeycode 84 = t Tkeycode 85 = u Ukeycode 86 = v Vkeycode 87 = w Wkeycode 88 = x Xkeycode 89 = y Ykeycode 90 = z Zkeycode 96 = KP_0 KP_0keycode 97 = KP_1 KP_1keycode 98 = KP_2 KP_2keycode 99 = KP_3 KP_3keycode 100 = KP_4 KP_4keycode 101 = KP_5 KP_5keycode 102 = KP_6 KP_6keycode 103 = KP_7 KP_7keycode 104 = KP_8 KP_8keycode 105 = KP_9 KP_9keycode 106 = KP_Multiply KP_Multiplykeycode 107 = KP_Add KP_Addkeycode 108 = KP_Separator KP_Separatorkeycode 109 = KP_Subtract KP_Subtractkeycode 110 = KP_Decimal KP_Decimalkeycode 111 = KP_Divide KP_Dividekeycode 112 = F1keycode 113 = F2keycode 114 = F3keycode 115 = F4keycode 116 = F5keycode 117 = F6keycode 118 = F7keycode 119 = F8keycode 120 = F9keycode 121 = F10keycode 122 = F11keycode 123 = F12keycode 124 = F13keycode 125 = F14keycode 126 = F15keycode 127 = F16keycode 128 = F17keycode 129 = F18keycode 130 = F19keycode 131 = F20keycode 132 = F21keycode 133 = F22keycode 134 = F23keycode 135 = F24keycode 136 = Num_Lockkeycode 137 = Scroll_Lockkeycode 187 = acute gravekeycode 188 = comma semicolonkeycode 189 = minus underscorekeycode 190 = period colonkeycode 192 = numbersign apostrophekeycode 210 = plusminus hyphen macronkeycode 211 =keycode 212 = copyright registeredkeycode 213 = guillemotleft guillemotrightkeycode 214 = masculine ordfemininekeycode 215 = ae AEkeycode 216 = cent yenkeycode 217 = questiondown exclamdownkeycode 218 = onequarter onehalf threequarterskeycode 220 = less greater barkeycode 221 = plus asterisk asciitildekeycode 227 = multiply divisionkeycode 228 = acircumflex Acircumflexkeycode 229 = ecircumflex Ecircumflexkeycode 230 = icircumflex Icircumflexkeycode 231 = ocircumflex Ocircumflexkeycode 232 = ucircumflex Ucircumflexkeycode 233 = ntilde Ntildekeycode 234 = yacute Yacutekeycode 235 = oslash Oobliquekeycode 236 = aring Aringkeycode 237 = ccedilla Ccedillakeycode 238 = thorn THORNkeycode 239 = eth ETHkeycode 240 = diaeresis cedilla currencykeycode 241 = agrave Agrave atilde Atildekeycode 242 = egrave Egravekeycode 243 = igrave Igravekeycode 244 = ograve Ograve otilde Otildekeycode 245 = ugrave Ugravekeycode 246 = adiaeresis Adiaeresiskeycode 247 = ediaeresis Ediaeresiskeycode 248 = idiaeresis Idiaeresiskeycode 249 = odiaeresis Odiaeresiskeycode 250 = udiaeresis Udiaeresiskeycode 251 = ssharp question backslashkeycode 252 = asciicircum degreekeycode 253 = 3 sterlingkeycode 254 = Mode_switch 使用<script language="javascript"> function keyevent(){ if(event.keyCode==13) alert("#$%#%#^^%"); } document.onkeydown = keyevent;</script>event.keyCode值為37﹐38﹐39﹐40對應按下的方向鍵分別是 左﹐上﹐右﹐下"javascript:if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;");if(event.keycode==13)就代表按下的是回车键盘"javascript:if (event.keyCode > 45 && event.keyCode < 57) event.returnValue = false;");<html><!--//this code by hongseheike--><head><script language="javascript">ns4 = (document.layers) ? true : false;ie4 = (document.all) ? true : false;function keyDown(e){ if(ns4){ var nkey=e.which;var iekey='现在是ns浏览器';var realkey=String.fromCharCode(e.which);}if(ie4){ var iekey=event.keyCode;var nkey='现在是ie浏览器';var realkey=String.fromCharCode(event.keyCode);if(event.keyCode==32){realkey='\' 空格\''}if(event.keyCode==13){realkey='\' 回车\''}if(event.keyCode==27){realkey='\' Esc\''}if(event.keyCode==16){realkey='\' Shift\''}if(event.keyCode==17){realkey='\' Ctrl\''}if(event.keyCode==18){realkey='\' Alt\''}}alert('ns浏览器中键值:'+nkey+'\n'+'ie浏览器中键值:'+iekey+'\n'+'实际键为'+realkey);}document.onkeydown = keyDown;if(ns4){ document.captureEvents(Event.KEYDOWN);}</script></head><body>//Javascript Document<hr><center><h3>请按任意一个键。。。。</h3></center></body></html>**********************************************************************使用javascript在WEB页面中截获键盘输入使用event对象的keyCode属性判断输入的键值eg:if(event.keyCode==13)alert(“enter!”);键值对应表A 0X65 U 0X85B 0X66 V 0X86C 0X67 W 0X87D 0X68 X 0X88E 0X69 Y 0X89F 0X70 Z 0X90G 0X71 0 0X48H 0X72 1 0X49I 0X73 2 0X50J 0X74 3 0X51K 0X75 4 0X52L 0X76 5 0X53M 0X77 6 0X54N 0X78 7 0X55O 0X79 8 0X56P 0X80 9 0X57Q 0X81 ESC 0X1BR 0X82 CTRL 0X11S 0X83 SHIFT 0X10T 0X84 ENTER 0XD如果要使用组合键,则可以利用event.ctrlKey,event.shiftKey,event .altKey判断是否按下了ctrl键、shift键以及alt键
转:http://www.cnblogs.com/DareOnly/archive/2009/02/26/1398928.html