Turn
<script type= "Text/javascript" Language=javascript charset= "UTF-8" >Document.onkeydown=function(event) {varE = Event | | window.event | | Arguments.callee.caller.arguments[0]; if(e && e.keycode==27) {//Press ESC //the things to do } if(e && e.keycode==113) {//Press F2 //the things to do } if(e && e.keycode==13) {//Enter key //the things to do } }; </script> as long as you define the actions of these keys, you will respond by pressing these keys in the browser, compatible with all current browsers.
1JS inside the keyboard events are often used, so the collection of keyboard events corresponding to the key code to share the following:2 KeyCode 8 =BackSpace BackSpace3 KeyCode 9 =tab TAB4 KeyCode 12 =Clear5 KeyCode 13 =Enter6 KeyCode 16 =shift_l7 KeyCode 17 =control_l8 KeyCode 18 =alt_l9 KeyCode 19 =PauseTen KeyCode 20 =Caps_lockKeyCode 27 =Escape EscapeKeyCode 32 =SpaceKeyCode 33 =PriorKeyCode 34 =NextKeyCode 35 =EndKeyCode 36 =Home37 KeyCode = LeftKeyCode 38 = upKeyCode 39 = RightKeyCode 40 = DownKeyCode 41 =SelectKeyCode 42 =PrintKeyCode 43 =ExecuteKeyCode 45 =InsertKeyCode 46 =DeleteKeyCode 47 = HelpKeyCode 48 = 0equal BracerightKeyCode 49 = 1Exclam OnesuperiorKeyCode 50 = 2Quotedbl Twosuperior51 KeyCode = 3Section ThreesuperiorKeyCode 52 = 4DollarKeyCode 53 = 5percentKeyCode 54 = 6AmpersandKeyCode 55 = 7Slash BraceleftKeyCode 56 = 8Parenleft BracketleftKeyCode 57 = 9parenright bracketrightPanax Notoginseng KeyCode 65 =a A66 KeyCode =b bKeyCode 67 =C c68 KeyCode =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 l77 KeyCode =m M Mu78 KeyCode =N NWuyi KeyCode 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_097 KeyCode =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 =F2Bayi KeyCode 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 =F1594 KeyCode 127 =F16KeyCode 128 =F17129 KeyCode =F18KeyCode 130 =F1998 KeyCode 131 =F20KeyCode 132 =F21133 KeyCode =F22101 KeyCode 134 =F23102 KeyCode 135 =F24103 KeyCode 136 =Num_lock104 KeyCode 137 =Scroll_lockKeyCode 187 =Acute grave106 KeyCode 188 =Comma semicolon107 KeyCode 189 =minus underscore108 KeyCode 190 =Period Colon109 KeyCode 192 =numbersign ApostropheKeyCode 210 =Plusminus hyphen Macron111 KeyCode 211 =112 KeyCode 212 =Copyright Registered113 KeyCode 213 =Guillemotleft guillemotrightKeyCode 214 =masculine OrdfeminineKeyCode 215 =AE AEKeyCode 216 =cent Yen117 KeyCode 217 =Questiondown Exclamdown118 KeyCode 218 =onequarter onehalf threequarters119 KeyCode 220 =Less Greater barKeyCode 221 =plus asterisk Asciitilde121 KeyCode 227 =Multiply Division122 KeyCode 228 =Acircumflex Acircumflex123 KeyCode 229 =Ecircumflex Ecircumflex124 KeyCode 230 =Icircumflex IcircumflexKeyCode 231 =Ocircumflex Ocircumflex126 KeyCode 232 =Ucircumflex Ucircumflex127 KeyCode 233 =Ntilde NtildeKeyCode 234 =Yacute Yacute129 KeyCode 235 =Oslash OobliqueKeyCode 236 =aring aring131 KeyCode 237 =Ccedilla CcedillaKeyCode 238 =Thorn Thorn133 KeyCode 239 =ETH ETH134 KeyCode 240 =diaeresis cedilla Currency135 KeyCode 241 =agrave agrave Atilde Atilde136 KeyCode 242 =Egrave Egrave137 KeyCode 243 =Igrave Igrave138 KeyCode 244 =ograve ograve Otilde Otilde139 KeyCode 245 =Ugrave UgraveKeyCode 246 =adiaeresis adiaeresis141 KeyCode 247 =ediaeresis ediaeresis142 KeyCode 248 =idiaeresis idiaeresis143 KeyCode 249 =odiaeresis odiaeresis144 KeyCode 250 =udiaeresis udiaeresis145 KeyCode 251 =ssharp question Backslash146 KeyCode 252 =Asciicircum degree147 KeyCode 253 = 3Sterling148 KeyCode 254 =Mode_switch149Use the KeyCode property of the event object to determine the input key valueEg:if(event.keycode==13) alert ("enter!");151Key-value correspondence tableA 0X65 U 0x85153 B 0X66 V 0x86154 C 0X67 W 0x87155 D 0X68 X 0x88156 E 0X69 Y 0x89157 F 0X70 Z 0x90158 G 0X71 0 0x48159 H 0X72 1 0x49160 I 0x73 2 0x50161 J 0X74 3 0x51162 K 0x75 4 0x52163 L 0X76 5 0x53164 M 0X77 6 0x54165 N 0X78 7 0x55166 O 0X79 8 0x56167 P 0X80 9 0x57168 Q 0X81 ESC 0x1b169 R 0X 0x11170 Ctrl + S 0X83 SHIFT 0x10171 T 0X84 ENTER 0xd172 If you want to use a combination of keys, you can determine whether you press the keys at the same time, such as CTRL, SHIFT, and the combination of the ALT key to determine whether to press the CTRL key, SHIFT key, and ALT key
Java Get keyboard events