JS in response, the key to enter the key program code

Source: Internet
Author: User
The code is as follows Copy Code

<script type= "Text/javascript" charset= "Utf-8" >
function response (obj) {
var $list = $ (obj);
var $children = $list. Children ();
var num= $children. Size ();//$list Total number
var current=0; The current selection
Addnow ()
$ (document). Bind (' KeyDown ', function (e) {
if ($list. Is (": visible")) {
if (E.keycode = = 40) {//Down
if (current<num-1) current = current +1;
Addnow ()
E.preventdefault ();
}else if (E.keycode ==38) {//Up
if (current > 0) current= current-1;
Addnow ()
E.preventdefault ();
}else if (E.keycode = = 13) {
The var url = $children. EQ (current). Find (' a '). attr (' href ');
document.location= URL;
}
}else{
current = 0;
Addnow ()
}
});

function Addnow () {
$children. Eq. addclass ("Now"). Siblings (). Removeclass (' Now ');
}

}

Response (' #ul ');

Some commonly used button-corresponding editors

Key pressed Javascript Key Code
Backspace 8
tab 9
Enter 13
Shift 16
Ctrl 17
Alt 18
Pause/break 19
Caps LOCK 20
Escape 27
Page UP 33
Page Down 34
End 35
Home 36
Left Arrow 37
Up ARROW 38
Right Arrow 39
Down ARROW 40
Insert 45
Delete 46
0 48
1 49
2 50
3 51
4 52
5 53
6 54
7 55
8 56
9 57
A 65
B 66
C 67
D 68
E 69
F 70
G 71
H 72
I 73
J 74
K 75
L 76
M 77
N 78
O 79
P 80
Q 81
R 82
S 83
T 84
U 85
V 86
W 87
X 88
Y 89
Z 90
Left window key 91
Right window key 92
Select key 93
Numpad 0 96
Numpad 1 97
Numpad 2 98
Numpad 3 99
Numpad 4 100
Numpad 5 101
Numpad 6 102
Numpad 7 103
Numpad 8 104
Numpad 9 105
Multiply 106
Add 107
Subtract 109
decimal point 110
Divide 111
F1 112
F2 113
F3 114
F4 115
F5 116
F6 117
F7 118
F8 119
F9 120
F10 121
F11 122
F12 123
NUM LOCK 144
Scroll LOCK 145
Semi-colon 186
Equal sign 187
Comma 188
Dash 189
Period 190
Forward slash 191
Grave Accent 192
Open bracket 219
Back slash 220
Close Braket 221
Single quote 222

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.