Property name |
Describe |
Value |
Description |
Altkey |
Check the state of the ALT key |
True if the ALT key is pressed or false |
Read-only |
Shiftkey |
Check the state of the SHIFT key |
When the SHIFT key is pressed, the value is true otherwise false |
Read-only |
Ctrlkey |
Check the state of the CTRL key |
True if the CTRL key is pressed or false |
Read-only |
Example: (When you click the button, it shows the status of the special keys pressed) <input type= "button" value= "click" onclick= "Showstate ()"/> <script> Function Show () { Alert ("Altkey:" +window.event.altkey + "\nshiftkey:" +window.event.shiftkey + "\nctrlkey:" +window.event.ctrlkey); }</script> |
KeyCode |
detects the internal code corresponding to the keyboard event |
|
Can be read and write, can be any one Unicode keyboard inside code. If no keyboard event is raised, the value is 0 |
Example: (press ENTER to get the next component to focus, quite press TAB) <input type= "text" onkeydown= "Nextblur ()"/> <input type= "Text"/> <script> function Nextblur () { if (window.event.keycode==13)//Enter the code The code for the Window.event.keycode=9;//tab key } </script> |
Srcelement |
Returns the element that triggered the event |
Object |
Read-only |
Example: (the name value of the button is displayed when the button is clicked) <input type= "button" value= "Min" name= "Fujian" onclick= "show ()"/> <input type= "button" value= "gan" name= "Jiangxi" onclick= "Show ()"/> <script> Function Show () { alert (window.event.srcElement.name); } </script> |
X, y |
The location of the mouse relative to the current browser |
Px |
Read-only |
Clientx,clienty |
The current position of the mouse relative to the Web page |
Px |
Read-only |
Offsetx,offsety |
The current position of the mouse relative to an area in the Web page |
Px |
Read-only |
Screenx,screeny |
Location relative to User monitor |
Px |
Read-only |
Description: When you click on a button to get (X,clientx,offsetx,screenx) easy to understand OffsetX; When you restore IE window to get (X,clientx,screenx), you will understand ScreenX When you switch the attributes of Div position between absolute and relative, you will understand the difference between X and Clientx. |
ReturnValue |
Sets or checks the value returned from the event |
The value in the true event is returned False the default action for events on the source object is canceled |
can read and write |
Example: Shield right mouse button, CTRL + N, SHIFT+F10, F5 refresh, backspace key function KeyDown () { Shield right mouse button, CTRL + N, SHIFT+F10, F5 refresh, backspace key if ((Window.event.altKey) && ((window.event.keycode==37) | | Masking ALT + arrow key ← (window.event.keycode==39))) {//masking ALT + arrow key → event.returnvalue=false;//prevent using ALT + arrow keys to advance or rewind a webpage } if ((event.keycode==8) | | | Mask BACKSPACE Delete key (event.keycode==116) | | Mask F5 Refresh Key (event.keycode==112) | | Shielded F1 Refresh key bitscn.com China Network Management Alliance (Event.ctrlkey && event.keycode==82)) {//ctrl + R event.keycode=0; Event.returnvalue=false; } if ((Event.ctrlkey) && (event.keycode==78))//Shielded CTRL + N Event.returnvalue=false; if ((Event.shiftkey) && (event.keycode==121))//shielded SHIFT+F10 Event.returnvalue=false; if (Window.event.srcElement.tagName = = "A" && Window.event.shiftKey) Window.event.returnValue = false; Screen shift and left mouse button to open a new page if ((Window.event.altKey) && (window.event.keycode==115)) {//shielded ALT+F4 Window.showmodelessdialog ("About:blank", "" "," dialogwidth:1px;dialogheight:1px "); return false;} } |
button |
Check the pressed mouse button |
0 No buttons. 1 Press the left button 2 Press the right button 3 Press the left and right key 4 Press the Middle key 5 Press the left and middle keys 6 Right-click and Middle-key 7 Press All the keys |
Only for Onmousedown,onmouseup and onmousemove events. Returns 0 for other events, regardless of mouse state (for example, onclick) |
Srcelement |
Detects onmouseover and onmouseout events that occur when the mouse leaves the element |
Object |
Read-only |
Toelement |
Detects the onmouseover and onmouseout events that occur when the mouse enters the element |
Object |
Read-only |
Type |
Return event name |
|
Returns the event name without "on" as the prefix, for example, the type returned by the onclick event is the click |