html-keycode碼大全

HTML

用戶名:<input type="text" id="UserAccount" onKeyPress="JumpByEnter(UserPwd)" />

密碼:<input name="UserPwd" type="password" onKeyPress="IsEnterKeyPress()">

JavaScript:

JumpByEnter(UserPwd) 函數功能:輸入完用戶名按回車,焦點轉向密碼輸入框

IsEnterKeyPress()功能:輸入完密碼並按回車,則登錄

function JumpByEnter(NextElement){
     var lKeyCode = (navigator.appname=="Netscape")?event.which:window.event.keyCode; //event.keyCode按的建的代碼,13表示回車
     if ( lKeyCode == 13 ){

    NextElement.focus();
     }

function IsEnterKeyPress(){
     var lKeyCode = (navigator.appname=="Netscape")?event.which:event.keyCode;
     if ( lKeyCode == 13 ){
       Login();
     }
     else
       return false;
   }

irfirefox2.0中不支持 window.event.keyCode,

但是我們可以用event.which代替。但是爲了使其能更具有普遍的兼容性,最好用event.keyCode|| event.which.

字母和數字鍵的鍵碼值(keyCode)
按鍵 鍵碼 按鍵 鍵碼 按鍵 鍵碼 按鍵 鍵碼
A 65 J 74 S 83 1 49
B 66 K 75 T 84 2 50
C 67 L 76 U 85 3 51
D 68 M 77 V 86 4 52
E 69 N 78 W 87 5 53
F 70 O 79 X 88 6 54
G 71 P 80 Y 89 7 55
H 72 Q 81 Z 90 8 56
I 73 R 82 0 48 9 57

   

 

數字鍵盤上的鍵的鍵碼值(keyCode) 功能鍵鍵碼值(keyCode)
按鍵 鍵碼 按鍵 鍵碼 按鍵 鍵碼 按鍵 鍵碼
0 96 8 104 F1 112 F7 118
1 97 9 105 F2 113 F8 119
2 98 * 106 F3 114 F9 120
3 99 + 107 F4 115 F10 121
4 100 Enter 108 F5 116 F11 122
5 101 - 109 F6 117 F12 123
6 102 . 110        
7 103 / 111        

   

 

控制鍵鍵碼值(keyCode)
按鍵 鍵碼 按鍵 鍵碼 按鍵 鍵碼 按鍵 鍵碼
BackSpace 8 Esc 27 Right Arrow 39 -_ 189
Tab 9 Spacebar 32 Dw Arrow 40 .> 190
Clear 12 Page Up 33 Insert 45 /? 191
Enter 13 Page Down 34 Delete 46 `~ 192
Shift 16 End 35 Num Lock 144 [{ 219
Control 17 Home 36 ;: 186 \| 220
Alt 18 Left Arrow 37 =+ 187 ]} 221
Cape Lock 20 Up Arrow 38 ,< 188 '" 222

 

多媒體鍵碼值(keyCode)
按鍵 鍵碼 按鍵 鍵碼 按鍵 鍵碼 按鍵 鍵碼
音量加 175            
音量減 174            
停止 179            
靜音 173            
瀏覽器 172            
郵件 180            
搜索 170            
收藏 171  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章