This article is mainly on the event Altkey,ctrlkey,shiftkey attribute analysis of detailed analytical introduction, the need for friends can come to the reference, I hope to help you.
event.altkey function: Detects whether the ALT key was pressed when the event occurred. Syntax: Event.altkey Take value: TRUE | False Description: The Altkey property is true to indicate that the ALT key was pressed and persisted when the event occurred, and False if the ALT key was not pressed. Altkey properties can be combined with a mouse or keyboard, used to make some quick operation. event.ctrlkey function: To detect if the CTRL key was pressed while the event occurred. Syntax: Event.ctrlkey Take value: TRUE | False Description: The Ctrlkey property is true to indicate that the CTRL key was pressed and persisted when the event occurred, and the CTRL key was not pressed as false. Ctrlkey properties can be combined with a mouse or keyboard, used to make some quick operation. event.shiftkey function: Detects if the SHIFT key is being pressed while the event occurs. Syntax: Event.shiftkey Take value: TRUE | False Description: The Shiftkey property is true to indicate that the SHIFT key was pressed and persisted when the event occurred, false and the SHIFT key was not pressed. Shiftkey properties can be combined with a mouse or keyboard, used to make some quick operation. Instance 1 combined Operation example. Code as follows: <input id= "Txt1" type= "text" value= "Hello world!" onclick= "CheckAlt (event)"/> <script type= "Text/javascript" > Function CheckAlt (oevent) { if (oevent.altkey) document.getElementById ("Txt1 "). Select (); </script> The effect of this code is: If you hold down the ALT key and click the text box above, you canSelect the text in the text box. Instance 2 combined Operation example. Code as follows: <input id= "Txt2" type= "text" value= "Hello world!" onclick= "cleartext (event)"/> <script type = "Text/javascript" > Function cleartext (oevent) { if (Oevent.ctrlkey && oevent.keycode==46) &nbs P document.getElementById ("Txt2"). Value = "";} </script> The effect of this code is: Use the "Ctrl+del" key to clear the contents of the text box above. (You must first get the focus of the text box.) This example applies only to IE browsers. ) Instance 3 combined Operation example. Code as follows: <div id= "box" style= "width:50px; HEIGHT:25PX;BORDER:1PX solid black; Background-color:red "onclick=" SetColor (event) ></div> <script type= "Text/javascript" > var b = True function SetColor (oevent) { if (Oevent.shiftkey && b) document.getElementById ("box"). Style. BackgroundColor = "Blue"; if (Oevent.shiftkey &&!b) document.getElementById ("box"). Style.backgroundcolor = "Red"; B =!b; } </script>   The effect of this code is: Hold down the "Shift" button and click on the top of the color block, you can change color block color