<SCRIPT type = "text/JavaScript">
Document. onkeydown = function (e ){
VaR EV = E | event;
If (EV. keycode = 13 & eV. altkey ){
Document. Location. href = "http://baidu.com ";
}
}
</SCRIPT>
Appendix event. keycode (JavaScript)
========================================================== ==============
Keycode 8 = backspace
Keycode 9 = tab Tab
Keycode 12 = clear
Keycode 13 = enter
Keycode 16 = shift_l
Keycode 17 = control_l
Keycode 18 = alt_l
Keycode 19 = pause
Keycode 20 = caps_lock
Keycode 27 = escape
Keycode 32 = space
Keycode 33 = prior
Keycode 34 = next
Keycode 35 = end
Keycode 36 = home
Keycode 37 = left
Keycode 38 = up
Keycode 39 = right
Keycode 40 = down
Keycode 41 = select
Keycode 42 = print
Keycode 43 = Execute
Keycode 45 = insert
Keycode 46 = Delete
Keycode 47 = Help
Keycode 48 = 0 equal braceright
Keycode 49 = 1 exclam onesuperior
Keycode 50 = 2 quotedbl twosuperior
Keycode 51 = 3 Section threesuperior
Keycode 52 = 4 dollar
Keycode 53 = 5 percent
Keycode 54 = 6 ampersand
Keycode 55 = 7 slash braceleft
Keycode 56 = 8 parenleft bracketleft
Keycode 57 = 9 parenright bracketright
Keycode 65 =
Keycode 66 = B
Keycode 67 = C
Keycode 68 = d
Keycode 69 = e eurosign
Keycode 70 = f
Keycode 71 = g
Keycode 72 = H
Keycode 73 = I
Keycode 74 = J
Keycode 75 = K
Keycode 76 = L
Keycode 77 = m mu
Keycode 78 = n
Keycode 79 = o
Keycode 80 = p
Keycode 81 = Q
Keycode 82 = r
Keycode 83 = s
Keycode 84 = t
Keycode 85 = u
Keycode 86 = V v
Keycode 87 = W
Keycode 88 = x
Keycode 89 = y
Keycode 90 = z
Keycode 96 = kp_0 kp_0
Keycode 97 = kp_1 kp_1
Keycode 98 = kp_2 kp_2
Keycode 99 = kp_3 kp_3
Keycode 100 = kp_4 kp_4
Keycode 101 = kp_5 kp_5
Keycode 102 = kp_6 kp_6
Keycode 103 = kp_7 kp_7
Keycode 104 = kp_8 kp_8
Keycode 105 = kp_9 kp_9
Keycode 106 = kp_multiply
Keycode 107 = kp_add
Key code 108 = kp_separator
Keycode 109 = kp_subtract
Key code 110 = kp_decimal
Keycode 111 = kp_divide
Key code 112 = F1
Keycode 113 = F2
Key code 114 = F3
Keycode 115 = F4
Key code 116 = F5
Keycode 117 = F6
Key code 118 = F7
Key code 119 = F8
Keycode 120 = F9
Keycode 121 = F10
Keycode 122 = F11
Key Code 123 = F12
Keycode 124 = f13
Keycode 125 = F14
Keycode 126 = F15
Keycode 127 = F16
Keycode 128 = f17
Keycode 129 = F18
Keycode 130 = F19
Keycode 131 = F20
Keycode 132 = F21
Keycode 133 = f22
Keycode 134 = F23
Keycode 135 = f24
Keycode 136 = num_lock
Keycode 137 = scroll_lock
Keycode 187 = acute grave
Keycode 188 = comma semicolon
Key code 189 = minus underscore
Key code 190 = period colon
Key code 192 = numbersign apostrophe
Key Code 210 = plusminus hyphen macron
Key code 211 =
Key code 212 = copyright registered
Key code 213 = guillemotleft guillemotright
Keycode 214 = masculine ordfeminine
Keycode 215 = AE AE
Keycode 216 = cent yen
Key code 217 = questiondown exclamdown
Key code 218 = onequarter onehalf threequarters
Keycode 220 = less greater bar
Key code 221 = plus asterisk asciitilde
Key code 227 = multiply Division
Keycode 228 = acircumflex
Key code 229 = ecircumflex
Keycode 230 = icircumflex
Key code 231 = ocircumflex
Keycode 232 = ucircumflex
Keycode 233 = ntilde
Keycode 234 = yacute
Key code 235 = Oslash ooblique
Key Code 236 = aring
Keycode 237 = ccedilla
Key code 238 = thorn
Keycode 239 = ETH
Key code 240 = diaeresis cedilla currency
Key code 241 = agrave atilde
Keycode 242 = egrave
Keycode 243 = igrave
Key code 244 = ograve otilde
Keycode 245 = ugrave
Keycode 246 = adiaeresis
Keycode 247 = ediaeresis
Keycode 248 = idiaeresis
Keycode 249 = odiaeresis
Keycode 250 = udiaeresis
Key code 251 = ssharp question backslash
Keycode 252 = asciicircum degree
Keycode 253 = 3 sterling
Keycode 254 = mode_switch
Use the keycode attribute of the event object to determine the Input key value
Eg: If (event. keycode = 13) Alert ("Enter !");
Key value table
A 0x65 u 0x85
B 0x66 v 0x86
C 0x67 w 0x87
D 0x68X0x88
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
If you want to use the combination key, you can use event. ctrlkey, event. shiftkey, event. altkey to determine whether Ctrl, shift, and ALT keys are pressed.
========================================================== ========
JS event object event attributes and methods:
1. Type: Transaction type, such as click in onlick;
2. srcelement/target: the transaction source, which is the production element;
3. button: Declares the mouse key to be pressed. An integer. 1 indicates the left button, 2 indicates the right button, and 4 indicates the middle button. If you press multiple keys, add these values to the wine, so "3" means that you press the key at the same time. (In Firefox, "0" indicates the left button, "1" indicates the center key, and "2" indicates the right button)
4. clientx/clienty: the time when the transaction is generated. The cursor is relative to the upper left corner of the visible document area in the browser window, that is to say, no matter where the document is migrated, as long as the transaction is generated in the upper left corner of the window, clientx and clienty are both 0. Therefore, in IE, to obtain the starting position of the coordinates produced by the transaction relative to the document, add
Document. Body. scrollleft and document. Body. scrolltop)
5. offsetx, offsety/layerx, layery: the time when the transaction is generated, and the position of the cursor relative to the upper left corner of the source element;
6. x, y/pagex, Pagey: returns the integer of the degree of coordinates relative to the mouse of the parent element;
7. altkey, ctrlkey, and shiftkey: return a Boolean value;
8. keycode: return the key at which the keyup transaction is generated.CodeAnd Unicode characters of the keypress transaction. (firefox2 does not support event. keycode. You can use event. Which to replace it)
9. element, toelement: The former refers to the document element that the mouse has moved in the MOU Search Engine Optimization ver transaction, and the latter refers to the file element that the mouse has moved to in the MOU Search Engine Optimization ut transaction;
10. cancelbubble: A boolean attribute. When it is set to true, the stop transaction is further blister to the element of the inclusion level; (E. cancelbubble = true; equivalent to E. stoppropagation ();)
11. returnvalue: A boolean attribute. When it is set to false, the browser can be organized to perform the default transaction action. (E. returnvalue = false; equivalent to E. preventdefault ();)
12. attachevent (), detachevent ()/addeventlistener (), removeeventlistener: two parameters are provided to register multiple transaction processing penalty functions for the DOM object transaction type, the first is the transaction type, and the second is the transaction processing penalty function. In
When the attachevent () transaction is executed, this keyword points to the window object, not the production element;
13. screenx and screeny: the position of the mouse pointer relative to the upper left corner of the monitor. If you want to open a new window, these two attributes are very important;
Some statements:
1. Event indicates the transaction status, such as the element that triggers the event object, the position and status of the mouse, and the key that is pressed;
2. The event object is valid only when the transaction is generated.
The event in Firefox is different from the event in IE. The global variables in IE are available at any time. The parameters in Firefox are used to seduce and use them, which is an extra variable in runtime.
In IE/opera, window. event is used and event is used in Firefox. in IE, the transaction object is event.srcelement, event.tar get is used in firefox, and both are available in opera.
3. The following two statements have the same results.
VaR EVT = (EVT )? EVT: (window. Event )? Window. Event: NULL );
VaR EVT = EVT | window. event; // in Firefox, window. event is null, and in IE, event is null.
4. Transaction bubbles in IE
In IE, transactions can bubble to the upper layer a little along the inclusion level, that is, the transaction processing penalty function defined by the DOM node at the grassroots level, if a node at the upper layer has a transaction processing penalty function of the same transaction type as that at the lower layer, the upper layer will also perform the penalty function. For example, the DIV tag contains a. If both tags have an onclick transaction processing penalty function, the fulfillment scene is to first perform The onclick transaction processing penalty function of tag, then execute the DIV's transaction processing penalty function. If the transaction processing penalty function does not fulfill the onclick transaction processing penalty function of the upper Div, set cancelbubble to true.