document.οnkeydοwn=function(){if(window.event.keyCode == 13){ do something}
1 keycode 8 = BackSpace BackSpace2 keycode 9 = Tab Tab3 keycode 12 = Clear4 keycode 13 = Enter5 keycode 16 = Shift_L6 keycode 17 = Control_L7 keycode 18 = Alt_L8 keycode 19 = Pause9 keycode 20 = Caps_Lock10 keycode 27 = Escape Escape11 keycode 32 = space space12 keycode 33 = Prior13 keycode 34 = Next14 keycode 35 = End15 keycode 36 = Home16 keycode 37 = Left17 keycode 38 = Up18 keycode 39 = Right19 keycode 40 = Down20 keycode 41 = Select21 keycode 42 = Print22 keycode 43 = Execute23 keycode 45 = Insert24 keycode 46 = Delete25 keycode 47 = Help26 keycode 48 = 0 equal braceright27 keycode 49 = 1 exclam onesuperior28 keycode 50 = 2 quotedbl twosuperior29 keycode 51 = 3 section threesuperior30 keycode 52 = 4 dollar31 keycode 53 = 5 percent32 keycode 54 = 6 ampersand33 keycode 55 = 7 slash braceleft34 keycode 56 = 8 parenleft bracketleft35 keycode 57 = 9 parenright bracketright36 keycode 65 = a A37 keycode 66 = b B38 keycode 67 = c C39 keycode 68 = d D40 keycode 69 = e E EuroSign41 keycode 70 = f F4243 keycode 71 = g G44 keycode 72 = h H45 keycode 73 = i I46 keycode 74 = j J47 keycode 75 = k K48 keycode 76 = l L49 keycode 77 = m M mu50 keycode 78 = n N51 keycode 79 = o O52 keycode 80 = p P53 keycode 81 = q Q at54 keycode 82 = r R55 keycode 83 = s S56 keycode 84 = t T57 keycode 85 = u U58 keycode 86 = v V59 keycode 87 = w W60 keycode 88 = x X61 keycode 89 = y Y62 keycode 90 = z Z63 keycode 96 = KP_0 KP_064 keycode 97 = KP_1 KP_165 keycode 98 = KP_2 KP_266 keycode 99 = KP_3 KP_367 keycode 100 = KP_4 KP_468 keycode 101 = KP_5 KP_569 keycode 102 = KP_6 KP_670 keycode 103 = KP_7 KP_771 keycode 104 = KP_8 KP_872 keycode 105 = KP_9 KP_973 keycode 106 = KP_Multiply KP_Multiply74 keycode 107 = KP_Add KP_Add7576 keycode 108 = KP_Separator KP_Separator77 keycode 109 = KP_Subtract KP_Subtract78 keycode 110 = KP_Decimal KP_Decimal79 keycode 111 = KP_Divide KP_Divide80 keycode 112 = F181 keycode 113 = F282 keycode 114 = F383 keycode 115 = F4848586 keycode 116 = F587 keycode 117 = F688 keycode 118 = F789 keycode 119 = F890 keycode 120 = F991 keycode 121 = F1092 keycode 122 = F1193 keycode 123 = F1294 keycode 124 = F1395 keycode 125 = F1496 keycode 126 = F1597 keycode 127 = F1698 keycode 128 = F1799 keycode 129 = F18100 keycode 130 = F19101 keycode 131 = F20102 keycode 132 = F21103 keycode 133 = F22104 keycode 134 = F23105 keycode 135 = F24106 keycode 136 = Num_Lock107 keycode 137 = Scroll_Lock108 keycode 187 = acute grave109 keycode 188 = comma semicolon110 keycode 189 = minus underscore111 keycode 190 = period colon112 keycode 192 = numbersign apostrophe113 keycode 210 = plusminus hyphen macron114 keycode 211 =115 keycode 212 = copyright registered116 keycode 213 = guillemotleft guillemotright117 keycode 214 = masculine ordfeminine118 keycode 215 = ae AE119 keycode 216 = cent yen120 keycode 217 = questiondown exclamdown121 keycode 218 = onequarter onehalf threequarters122 keycode 220 = less greater bar123 keycode 221 = plus asterisk asciitilde124 keycode 227 = multiply division125126 keycode 228 = acircumflex Acircumflex127 keycode 229 = ecircumflex Ecircumflex128 keycode 230 = icircumflex Icircumflex129 keycode 231 = ocircumflex Ocircumflex130 keycode 232 = ucircumflex Ucircumflex131 keycode 233 = ntilde Ntilde132 keycode 234 = yacute Yacute133 keycode 235 = oslash Ooblique134 keycode 236 = aring Aring135 keycode 237 = ccedilla Ccedilla136 keycode 238 = thorn THORN137 keycode 239 = eth ETH138 keycode 240 = diaeresis cedilla currency139 keycode 241 = agrave Agrave atilde Atilde140 keycode 242 = egrave Egrave141 keycode 243 = igrave Igrave142 keycode 244 = ograve Ograve otilde Otilde143 keycode 245 = ugrave Ugrave144 keycode 246 = adiaeresis Adiaeresis145 keycode 247 = ediaeresis Ediaeresis146 keycode 248 = idiaeresis Idiaeresis147 keycode 249 = odiaeresis Odiaeresis148 keycode 250 = udiaeresis Udiaeresis149 keycode 251 = ssharp question backslash150 keycode 252 = asciicircum degree151 keycode 253 = 3 sterling152 keycode 254 = Mode_switch153154 使用event对象的keyCode属性判断输入的键值155 eg:if(event.keyCode==13)alert(“enter!”);156 键值对应表157 A 0X65 U 0X85158 B 0X66 V 0X86159 C 0X67 W 0X87160 D 0X68 X 0X88161 E 0X69 Y 0X89162 F 0X70 Z 0X90163 G 0X71 0 0X48164 H 0X72 1 0X49165 I 0X73 2 0X50166 J 0X74 3 0X51167 K 0X75 4 0X52168 L 0X76 5 0X53169 M 0X77 6 0X54170 N 0X78 7 0X55171 O 0X79 8 0X56172 P 0X80 9 0X57173 Q 0X81 ESC 0X1B174 R 0X82 CTRL 0X11175 S 0X83 SHIFT 0X10176 T 0X84 ENTER 0XD如果要使用组合键,则可以利用event.ctrlKey,event.shiftKey,event .altKey判断是否按下了ctrl键、shift键以及alt键