How to obtain
It is basically determined from the Action event.
Processing in IE
In IE, the window object contains the event. See the example below:
[Html]
<! -- Add by oscar999 -->
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<Meta name = "Author" CONTENT = "oscar999">
<Script>
Function showWinEvent ()
{
If (window. event. altKey)
{
Alert ("you pressed Alt Key ");
} Else if (window. event. ctrlKey)
{
Alert ("you pressed Ctrl Key ");
} Else if (window. event. shiftKey)
{
Alert ("you pressed Shift Key ");
} Else {
// Alert (window. event. button)
}
}
</Script>
</HEAD>
<BODY>
<Input onclick = "showWinEvent ()" type = "button" value = "click me">
</BODY>
</HTML>
<! -- Add by oscar999 -->
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<Meta name = "Author" CONTENT = "oscar999">
<Script>
Function showWinEvent ()
{
If (window. event. altKey)
{
Alert ("you pressed Alt Key ");
} Else if (window. event. ctrlKey)
{
Alert ("you pressed Ctrl Key ");
} Else if (window. event. shiftKey)
{
Alert ("you pressed Shift Key ");
} Else {
// Alert (window. event. button)
}
}
</Script>
</HEAD>
<BODY>
<Input onclick = "showWinEvent ()" type = "button" value = "click me">
</BODY>
</HTML>
The above work can be performed in IE and Chrome, but there is a problem in firefox, the undefined error will be reported, because the window object of firefox does not contain event.
Firefox compatibility
[Html]
<! -- Add by oscar999 -->
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<Meta name = "Author" CONTENT = "oscar999">
<Script>
Function showWinEvent (evn)
{
If (evn. altKey)
{
Alert ("you pressed Alt Key ");
} Else if (evn. ctrlKey)
{
Alert ("you pressed Ctrl Key ");
} Else if (evn. shiftKey)
{
Alert ("you pressed Shift Key ");
} Else {
// Alert (window. event. button)
}
}
</Script>
</HEAD>
<BODY>
<Input onclick = "showWinEvent (event)" type = "button" value = "click me">
</BODY>
</HTML>
<! -- Add by oscar999 -->
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<Meta name = "Author" CONTENT = "oscar999">
<Script>
Function showWinEvent (evn)
{
If (evn. altKey)
{
Alert ("you pressed Alt Key ");
} Else if (evn. ctrlKey)
{
Alert ("you pressed Ctrl Key ");
} Else if (evn. shiftKey)
{
Alert ("you pressed Shift Key ");
} Else {
// Alert (window. event. button)
}
}
</Script>
</HEAD>
<BODY>
<Input onclick = "showWinEvent (event)" type = "button" value = "click me">
</BODY>
</HTML>