Dab tsi yog keyCode nkag?
Dab tsi yog keyCode nkag?

Video: Dab tsi yog keyCode nkag?

Video: Dab tsi yog keyCode nkag?
Video: Peb tsev neeg tawg ua sab ua sua 7/20/2017 2024, Hlis ntuj nqeg
Anonim

#Keycode qhov tseem ceeb

Ntsiab Code
backspace 8
tab 9
nkag 13
ua haujlwm 16

Ib yam li ntawd, 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.

Ib yam li ntawd, cov lej tseem ceeb hauv JavaScript yog dab tsi? Nov yog cov npe ntawm ntau ntawm JavaScript KeyCodes

Nias lub keyboard JavaScript Key Code tus nqi
backspace 8
tab 9
nkag 13
ua haujlwm 16

Ntawm no, koj ua li cas thiaj li tshwm sim nyem rau ntawm nias Enter?

Rau ua rau a nyem khawm ntawm ENTER tus yuam sij , Peb tuaj yeem siv ib qho keyup(), keydown() thiab keypress() xwm txheej ntawm jQuery. keyup(): Qhov no xwm txheej tshwm sim thaum a tus yuam sij keyboard tso tawm. Txoj kev ib yam ua rau qhov keyup xwm txheej , los yog khiav a muaj nuj nqi thaum keyup xwm txheej tshwm sim.

Puas yog kev tshwm sim keyCode deprecated?

keyCode . var key = xwm txheej . Yog tias cov cuab yeej ntawd muaj tus nqi tsis tau txhais, peb yuav nrhiav keyCode . keyCode muaj nyob rau hauv yuav luag tag nrho cov browsers, tab sis yog tsis pom zoo hauv spec.

Pom zoo: