Cov txheej txheem:

Dab tsi yog keyCode hauv JavaScript?
Dab tsi yog keyCode hauv JavaScript?

Video: Dab tsi yog keyCode hauv JavaScript?

Video: Dab tsi yog keyCode hauv JavaScript?
Video: Leng Yang - Yog Vim Dab Tsi (Official Full Song | Nkauj Tawm Tshiab) 2020/05/24 2024, Hlis ntuj nqeg
Anonim

JavaScript KeyCode

Qhov kev tshwm sim keydown tshwm sim thaum tus yuam sij keyboard raug nias, thiab nws tau ua raws ib zaug los ntawm kev ua tiav ntawm keypress tshwm sim. Qhov kev tshwm sim keyup yog tsim thaum tus yuam sij raug tso tawm.

Tib neeg kuj nug, keyCode yog dab tsi rau nkag rau hauv JavaScript?

#Keycode qhov tseem ceeb

Ntsiab Code
backspace 8
tab 9
nkag 13
ua haujlwm 16

Ib yam li ntawd, kuv yuav nrhiav tau kuv tus lej yuam sij li cas? Yog tias muaj cov lej tseem ceeb, cov no yog cov chaw sib xws:

  1. Nyob rau hauv cov ntaub ntawv ntawm lub tsheb. Qee lub sij hawm tus lej tseem ceeb nyob hauv phau ntawv tsheb lossis ntawm daim ntawv lo nrog lub xauv lossis tus yuam sij.
  2. Ntawm tus yuam sij.
  3. Ntawm lub phaj hlau hauv lub hnab looj tes lossis lwm qhov hauv lub tsheb.
  4. Nyob ntawm lub xauv lub tsev.

Hauv qhov no, keyCode yog dab tsi?

Cov keyCode Cov cuab yeej xa rov qab cov cim cim Unicode ntawm tus yuam sij uas ua rau muaj kev tshwm sim onkeypress, lossis Unicode tus lej code ntawm tus yuam sij uas ua rau qhov kev tshwm sim onkeydown lossis onkeyup tshwm sim. Cov cim cim - Tus lej uas sawv cev rau tus cim ASCII. Cov lej tseem ceeb - Tus lej uas sawv cev rau tus yuam sij tiag tiag ntawm cov keyboard.

Dab tsi yog keyCode rau spacebar?

Daim Ntawv Ntxiv B. Cov Ntsiab Cai ntawm Cov Ntsiab Lus Tseem Ceeb

Ntsiab Tus nqi tseem ceeb
Scroll Xauv 145
Hloov 16
Spacebar 32
Tab 9

Pom zoo: