JS Judging keyboard keys

Source: Internet
Author: User

Mark To:http://www.cnblogs.com/hanwenhua/articles/3365154.html

Window.document.onkeydown = Disablerefresh;function Disablerefresh (evt) {evt = (evt)? Evt:window.eventif (Evt.keycode) {   if (Evt.keycode = =) {    //do something  }}} KeyCode 8 = BackSpace Backspacekeycode 9 = Tab Tabkeycode = Clearkeycode = Enterkeycode = Shift_lkeycode + = Con Trol_lkeycode = Alt_lkeycode = Pausekeycode = Caps_lockkeycode = Escape Escapekeycode = Space Spacekeycode Priorkeycode = Nextkeycode = Endkeycode = Homekeycode PNs = Leftkeycode = Upkeycode = Rightkeycode 40 = Downkeycode = Selectkeycode = Printkeycode = Executekeycode = Insertkeycode = Deletekeycode de = 0 Equal bracerightkeycode = 1 Exclam onesuperiorkeycode 2 quotedbl twosuperiorkeycode = 3 section Three Superiorkeycode 4 Dollarkeycode = 5 Percentkeycode = 6 Ampersandkeycode = 7 Slash Braceleftkeycode 8 PA Renleft Bracketleftkeycode = 9 Parenright BracketrightkeyCode Akeycode = A = b Bkeycode = c Ckeycode = d Dkeycode = e e Eurosignkeycode = f Fkeycode = g GKEYC Ode = h Hkeycode = i ikeycode = J Jkeycode (k kkeycode) = l Lkeycode * = m M mukeycode = n Nkeycode 79 = o Okeycode = p Pkeycode bayi = q Q atkeycode = R Rkeycode = s Skeycode p = t Tkeycode = u Ukeycode = v Vke Ycode = W Wkeycode = x xkeycode = y Ykeycode = z zkeycode = kp_0 kp_0keycode = kp_1 Kp_1keycode 98 = kp_ 2 Kp_2keycode = kp_3 Kp_3keycode = kp_4 Kp_4keycode 101 = kp_5 Kp_5keycode 102 = kp_6 Kp_6keycode 103 = KP_7 KP_7ke Ycode 104 = Kp_8 Kp_8keycode = kp_9 Kp_9keycode 106 = kp_multiply Kp_multiplykeycode 107 = Kp_add KP_Addkeycode 108 = Kp_separator Kp_separatorkeycode 109 = kp_subtract Kp_subtractkeycode = kp_decimal Kp_decimalkeycode 111 = KP_Divide K P_dividekeycode F3keycode = F1keycode 113 = F2keycode = F4keycode, = F5keycode = 117 Ycode 119 = F8keycode 120 = F9keycode 121 = F10keycode 122 = F11keycode 123 = F12keycode 124 = F13keycode = F14keycode 126 = F15keycode 127 = F16keycode = F17keycode 129 = F18keycode = F19keycode 131 = F20keycode = F21keycode 133 = F22keycode 134 = F23 KeyCode 135 = F24keycode 136 = Num_lockkeycode 137 = Scroll_lockkeycode 187 = Acute Gravekeycode 188 = comma SEMICOLONKEYC Ode 189 = minus Underscorekeycode = period Colonkeycode 192 = numbersign Apostrophekeycode = Plusminus hyphen MACR Onkeycode 211 =keycode 212 = Copyright Registeredkeycode 213 = guillemotleft Guillemotrightkeycode 214 = masculine Ordfemi Ninekeycode 215 = ae Aekeycode 216 = cent Yenkeycode 217 = questiondown Exclamdownkeycode 218 = Onequarter Onehalf threequ Arterskeycode = Less greater barkeycode 221 = plus asterisk asciitildekeycode 227 = multiply Divisionkeycode 228 = ACI Rcumflex Acircumflexkeycode 229 = Ecircumflex Ecircumflexkeycode = Icircumflex Icircumflexkeycode 231 = Ocircumflex Oc Ircumflexkeycode 232 = ucircumflex ucircumflexkeycode 233 = Ntilde Ntildekeycode 234 = yacute Yacutekeycode 235 = oslash Oobliquekeycode 236 = Ari ng Aringkeycode 237 = Ccedilla Ccedillakeycode 238 = Thorn Thornkeycode 239 = eth Ethkeycode = diaeresis cedilla Curre Ncykeycode 241 = Agrave Agrave atilde atildekeycode 242 = egrave Egravekeycode 243 = igrave Igravekeycode 244 = Ograve Ogr Ave Otilde Otildekeycode 245 = ugrave Ugravekeycode 246 = adiaeresis Adiaeresiskeycode 247 = ediaeresis Ediaeresiskeycode 248 = idiaeresis Idiaeresiskeycode 249 = odiaeresis Odiaeresiskeycode = udiaeresis Udiaeresiskeycode 251 = Ssharp ques tion Backslashkeycode 252 = asciicircum Degreekeycode 253 = 3 Sterlingkeycode 254 = Mode_switch Use the KeyCode property of the event object to determine the input key value E G:if (event.keycode==13) {var iekey=event.keycode;//gets the key value, the digital form of the
var realkey=string.fromcharcode (Iekey)//Converts the key value in digital form to the real key alert (Realkey);} Key value corresponds to table a 0X65 U 0x85b 0X66 V 0x86c 0X67 W 0x87d 0X68 X 0x88e 0X69 Y 0x89f 0X70 Z 0x90g 0X71 0 0X   48H 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 If you want to use a composite key, you can take advantage of the event . ctrlkey,event.shiftkey,event. Altkey to determine if the CTRL, SHIFT, and ALT keys are pressed

JS Judging keyboard keys

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.