Get keyboard event "Go" in JS

Source: Internet
Author: User

<script type= "Text/javascript" Language=javascript charset= "UTF-8" > 2       document.onkeydown=function (event) {3             var e = Event | | window.event | | arguments.callee.caller.arguments[0]; 4             if (e && e.keycode==27) {//Press ESC  5                 //What to do 6               } 7             if (e && e.keycode==113) {//press F2  8                  //What to do 9                }              if (e && e.keycode==13) {//Enter key one                  //To do things             }13         }; </script>


1 JS inside the keyboard events are often used, so the collection of keyboard events corresponding key code to share under: 2 keycode 8 = BackSpace BackSpace 3 keycode 9 = tab TAB 4 keycode = Clear 5 ke Ycode = Enter 6 keycode = shift_l 7 keycode = control_l 8 keycode = alt_l 9 keycode = Pause keycode Caps_lock = KeyCode = Escape Escape keycode = Space KeyCode = Prior + keycode = Next KeyCode 3  5 = End KeyCode = Home KeyCode PNs = left keycode + = up keycode (+) = right KeyCode + = down KeyCode KeyCode = Select = Print KeyCode = Execute KeyCode = Insert keycode = Delete + keycode = H ELP keycode = 0 equal braceright keycode 1 exclam onesuperior 2 keycode quotedbl = Twosuperior  Ode = 3 section Threesuperior keycode = 4 dollar keycode 6 = 5 percent KeyCode Ampersand 7 Slash braceleft KeyCode 65 = 8 Parenleft bracketleft/keycode 9 = parenright Bracketright PNS keycode A-A-keycode-B-BKeyCode = c c keycode (keycode) = d d (= e eurosign) keycode = f F keycode 72 = g g keycode = h-H keycode = i i-keycode-G = J-J KeyCode-k = K.-K-keycode-M = l L-keycode * * = M. m mu keycode 7 8 = n N keycode-o-o-keycode = P P-keycode Bayi = q q at Si keycode = r r keycode  T-T-keycode-keycode = U-U-keycode-keycode = v-V-keycode-keycode = w-X-X-A-+----------------= y y 90 = Z Z keycode = kp_0 kp_0 keycode = kp_1 kp_1 (keycode 98 = kp_2 kp_2) keycode = Kp_3 Kp_3 Kp_4 kp_4 keycode 101 = kp_5 Kp_5 the KeyCode 102 = kp_6 Kp_6 keycode 103 = kp_7 kp_7 + keycode 104 = Kp_8 KP_ 8 keycode = Kp_9 kp_9 keycode 106 = kp_multiply kp_multiply keycode 107 = Kp_add Kp_add-KeyCode 108 = KP_S Eparator kp_separator keycode 109 = kp_subtract kp_subtract All keycode = Kp_decimal Kp_decimal + keyCode 111 = KP_ Divide Kp_divide KEYCOde F1 = keycode 113 = F2 Bayi keycode [F3] keycode [F4] * * * * * * keycode * F5 * + keycode 117 = F6 + keycod E 118 = F7 KeyCode 119 = F8, keycode = F9, keycode 121 = F10, keycode 122 = F11-KeyCode 123 = F12 Keyco De 124 = F13 keycode = F14, keycode 126 = F15 94 KeyCode 127 = F16 (keycode) = F17, keycode 129 = F18 k Eycode * = F19 98 KeyCode 131 = F20 The KeyCode-F21100 keycode = 133 F22101 = keycode 134 F23102 = keycode 135 F241 = KeyCode 136 = num_lock104 KeyCode 137 = scroll_lock105 KeyCode 187 = Acute grave106 keycode 188 = comma semicolon107 ke Ycode 189 = minus underscore108 keycode = period colon109 keycode 192 = numbersign apostrophe110 keycode = plusmin US hyphen macron111 keycode 211 =112 keycode 212 = Copyright registered113 keycode 213 = Guillemotleft guillemotright114 k Eycode 214 = masculine ordfeminine115 keycode 215 = AE AE116 keycode 216 = cent yen117 keycode 217 = Questiondown Exclamdo wn118 KeyCode 218 = OneqUarter onehalf threequarters119 keycode = Less greater bar120 keycode 221 = plus asterisk asciitilde121 keycode 227 = Multiply division122 keycode 228 = Acircumflex Acircumflex123 keycode 229 = Ecircumflex Ecircumflex124 keycode = Icirc Umflex Icircumflex125 keycode 231 = Ocircumflex Ocircumflex126 keycode 232 = Ucircumflex Ucircumflex127 keycode 233 = Ntil De Ntilde128 keycode 234 = Yacute Yacute129 keycode 235 = Oslash Ooblique130 keycode 236 = aring Aring131 keycode 237 = cc Edilla Ccedilla132 keycode 238 = Thorn THORN133 keycode 239 = eth ETH134 keycode = diaeresis cedilla currency135 Keyco  De 241 = agrave agrave Atilde Atilde136 keycode 242 = egrave Egrave137 keycode 243 = igrave Igrave138 keycode 244 = Ograve Ograve Otilde Otilde139 keycode 245 = ugrave Ugrave140 keycode 246 = adiaeresis Adiaeresis141 keycode 247 = ediaeresis Ed iaeresis142 keycode 248 = idiaeresis Idiaeresis143 keycode 249 = odiaeresis Odiaeresis144 keycode = udiaeresis udiaere sis145 keycode 251 = SSHARP question backslash146 keycode 252 = asciicircum degree147 keycode 253 = 3 sterling148 keycode 254 = mode_switch149 using E The KeyCode property of the Vent object determines the input key value of Eg:if (event.keycode==13) alert ("enter!"); 151 key value corresponding table 0X65 U 0x85153 B 0X66 V 0x86154 C 0X67 W 0x87155 D 0X68 X 0x88156 E 0X69 Y 0x89157 F 0 X70 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 0X1B 169 R 0X82 CTRL 0x11170 S 0X83 SHIFT 0x10171 T 0X84 ENTER 0xd172 If you want to use a combination of keys, you can determine whether the keys are pressed at the same time, such as the CTRL key, SHIFT key, and the combination of the ALT key can be used to To determine if you have pressed the CTRL key, the SHIFT key, and the ALT key

Get keyboard event "Go" in JS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.