How to obtain
It is basically determined from the Action event.
In ie, the window object contains the event. See the example below:
<!--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
<!--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>
Analysis and advanced
...