[收藏]javascript keycode大全
keycode9=TabTab
keycode12=Clear
keycode13=Enter
keycode16=Shift_L
keycode17=Control_L
keycode18=Alt_L
keycode19=Pause
keycode20=Caps_Lock
keycode27=EscapeEscape
keycode32=spacespace
keycode33=Prior
keycode34=Next
keycode35=End
keycode36=Home
keycode37=Left
keycode38=Up
keycode39=Right
keycode40=Down
keycode41=Select
keycode42=Print
keycode43=Execute
keycode45=Insert
keycode46=Delete
keycode47=Help
keycode48=0equalbraceright
keycode49=1exclamonesuperior
keycode50=2quotedbltwosuperior
keycode51=3sectionthreesuperior
keycode52=4dollar
keycode53=5percent
keycode54=6ampersand
keycode55=7slashbraceleft
keycode56=8parenleftbracketleft
keycode57=9parenrightbracketright
keycode65=aA
keycode66=bB
keycode67=cC
keycode68=dD
keycode69=eEEuroSign
keycode70=fF
keycode71=gG
keycode72=hH
keycode73=iI
keycode74=jJ
keycode75=kK
keycode76=lL
keycode77=mMmu
keycode78=nN
keycode79=oO
keycode80=pP
keycode81=qQat
keycode82=rR
keycode83=sS
keycode84=tT
keycode85=uU
keycode86=vV
keycode87=wW
keycode88=xX
keycode89=yY
keycode90=zZ
keycode96=KP_0KP_0
keycode97=KP_1KP_1
keycode98=KP_2KP_2
keycode99=KP_3KP_3
keycode100=KP_4KP_4
keycode101=KP_5KP_5
keycode102=KP_6KP_6
keycode103=KP_7KP_7
keycode104=KP_8KP_8
keycode105=KP_9KP_9
keycode106=KP_MultiplyKP_Multiply
keycode107=KP_AddKP_Add
keycode108=KP_SeparatorKP_Separator
keycode109=KP_SubtractKP_Subtract
keycode110=KP_DecimalKP_Decimal
keycode111=KP_DivideKP_Divide
keycode112=F1
keycode113=F2
keycode114=F3
keycode115=F4
keycode116=F5
keycode117=F6
keycode118=F7
keycode119=F8
keycode120=F9
keycode121=F10
keycode122=F11
keycode123=F12
keycode124=F13
keycode125=F14
keycode126=F15
keycode127=F16
keycode128=F17
keycode129=F18
keycode130=F19
keycode131=F20
keycode132=F21
keycode133=F22
keycode134=F23
keycode135=F24
keycode136=Num_Lock
keycode137=Scroll_Lock
keycode187=acutegrave
keycode188=commasemicolon
keycode189=minusunderscore
keycode190=periodcolon
keycode192=numbersignapostrophe
keycode210=plusminushyphenmacron
keycode211=
keycode212=copyrightregistered
keycode213=guillemotleftguillemotright
keycode214=masculineordfeminine
keycode215=aeAE
keycode216=centyen
keycode217=questiondownexclamdown
keycode218=onequarteronehalfthreequarters
keycode220=lessgreaterbar
keycode221=plusasteriskasciitilde
keycode227=multiplydivision
keycode228=acircumflexAcircumflex
keycode229=ecircumflexEcircumflex
keycode230=icircumflexIcircumflex
keycode231=ocircumflexOcircumflex
keycode232=ucircumflexUcircumflex
keycode233=ntildeNtilde
keycode234=yacuteYacute
keycode235=oslashOoblique
keycode236=aringAring
keycode237=ccedillaCcedilla
keycode238=thornTHORN
keycode239=ethETH
keycode240=diaeresiscedillacurrency
keycode241=agraveAgraveatildeAtilde
keycode242=egraveEgrave
keycode243=igraveIgrave
keycode244=ograveOgraveotildeOtilde
keycode245=ugraveUgrave
keycode246=adiaeresisAdiaeresis
keycode247=ediaeresisEdiaeresis
keycode248=idiaeresisIdiaeresis
keycode249=odiaeresisOdiaeresis
keycode250=udiaeresisUdiaeresis
keycode251=ssharpquestionbackslash
keycode252=asciicircumdegree
keycode253=3sterling
keycode254=Mode_switch
使用
<scriptlanguage="javascript">
functionkeyevent(){
if(event.keyCode==13)
alert("#$%#%#^^%");
}
document.onkeydown=keyevent;
</script>
event.keyCode值為37﹐38﹐39﹐40對應按下的方向鍵分別是左﹐上﹐右﹐下
"javascript:if(event.keyCode<45||event.keyCode>57)event.returnValue=false;");
if(event.keycode==13)就代表按下的是回车键盘
"javascript:if(event.keyCode>45&&event.keyCode<57)event.returnValue=false;");
<html>
<!--//thiscodebyhongseheike-->
<head>
<scriptlanguage="javascript">
ns4=(document.layers)?true:false;
ie4=(document.all)?true:false;
functionkeyDown(e){
if(ns4){
varnkey=e.which;
variekey='现在是ns浏览器';
varrealkey=String.fromCharCode(e.which);
}
if(ie4){
variekey=event.keyCode;
varnkey='现在是ie浏览器';
varrealkey=String.fromCharCode(event.keyCode);
if(event.keyCode==32){realkey='\'空格\''}
if(event.keyCode==13){realkey='\'回车\''}
if(event.keyCode==27){realkey='\'Esc\''}
if(event.keyCode==16){realkey='\'Shift\''}
if(event.keyCode==17){realkey='\'Ctrl\''}
if(event.keyCode==18){realkey='\'Alt\''}
}
alert('ns浏览器中键值:'+nkey+'\n'+'ie浏览器中键值:'+iekey+'\n'+'实际键为'+realkey);
}
document.onkeydown=keyDown;
if(ns4){
document.captureEvents(Event.KEYDOWN);}
</script>
</head>
<body>
//JavascriptDocument
<hr>
<center>
<h3>请按任意一个键。。。。</h3>
</center>
</body>
</html>
**********************************************************************
使用javascript在WEB页面中截获键盘输入
使用event对象的keyCode属性判断输入的键值
eg:if(event.keyCode==13)alert(“enter!”);
键值对应表
A 0X65 U 0X85
B 0X66 V 0X86
C 0X67 W 0X87
D 0X68 X 0X88
E 0X69 Y 0X89
F 0X70 Z 0X90
G 0X71 0 0X48
H 0X72 1 0X49
I 0X73 2 0X50
J 0X74 3 0X51
K 0X75 4 0X52
L 0X76 5 0X53
M 0X77 6 0X54
N 0X78 7 0X55
O 0X79 8 0X56
P 0X80 9 0X57
Q 0X81 ESC 0X1B
R 0X82 CTRL 0X11
S 0X83 SHIFT 0X10
T 0X84 ENTER 0XD
如果要使用组合键,则可以利用event.ctrlKey,event.shiftKey,event.altKey判断是否按下了ctrl键、shift键以及alt键