Html
User name: <input type= "text" id= "UserAccount" onkeypress= "Jumpbyenter (userpwd)"/>
Password: <input name= "userpwd" type= "password" onkeypress= "isenterkeypress ()" >
Javascript:
Jumpbyenter (userpwd) function function: After entering the user name press ENTER, focus turn to password input box
Isenterkeypress () function: Enter the password and press ENTER, then login
function Jumpbyenter (nextelement) {
var Lkeycode = (navigator.appname== "Netscape")? Event.which:window.event.keyCode; Event.keycode Press the built code, 13 means enter
if (Lkeycode = = 13) {
Nextelement.focus ();
}
function isenterkeypress () {
var Lkeycode = (navigator.appname== "Netscape")? Event.which:event.keyCode;
if (Lkeycode = = 13) {
Login ();
}
Else
return false;
}
Window.event.keyCode is not supported in irfirefox2.0,
But we can use Event.which instead. But in order to make it more universal compatible, it is best to use event.keycode| | Event.which.
KeyCode table
| Key values for letters and number keys (KeyCode) |
| Keys |
Key code |
Keys |
Key code |
Keys |
Key code |
Keys |
Key code |
| 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 |
| Key values for keys on the numeric keypad (keycode) |
Function key code value (KeyCode) |
| Keys |
Key code |
Keys |
Key code |
Keys |
Key code |
Keys |
Key code |
| 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 |
|
|
|
|
| Control key Code value (KeyCode) |
| Keys |
Key code |
Keys |
Key code |
Keys |
Key code |
Keys |
Key code |
| 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 |
| Multimedia key code value (KeyCode) |
| Keys |
Key code |
Keys |
Key code |
Keys |
Key code |
Keys |
Key code |
| Volume Plus |
175 |
|
|
|
|
|
|
| Volume reduction |
174 |
|
|
|
|
|
|
| Stop it |
179 |
|
|
|
|
|
|
| Mute |
173 |
|
|
|
|
|
|
| Browser |
172 |
|
|
|
|
|
|
| Mail |
180 |
|
|
|
|
|
|
| Search |
170 |
|
|
|
|
|
|
| Collection |
171 |
|
Source: http://www.cnblogs.com/hsapphire/archive/2009/12/16/1625642.html
PS: If we join a website in the IFRAME and then log in .... Will you be able to record the username and password?
Event.keycode usage and keycode table in JS