event.altKey
Function: Detect whether the Alt key is pressed when the event occurs.
Syntax: event.altKey
Value: true | false
Description:
The altKey attribute is true to indicate that the Alt key was pressed and held when the event occurred, and false to indicate that the Alt key was not pressed.
The altKey attribute can be used in combination with the mouse or keyboard, and is mostly used to create some shortcut operations.
event.ctrlKey
Function: Detect whether the Ctrl key is pressed when the event occurs.
Syntax: event.ctrlKey
Value: true | false
Description:
The ctrlKey attribute is true if the Ctrl key is pressed and held when the event occurs, and false if the Ctrl key is not pressed.
The ctrlKey attribute can be used in conjunction with the mouse or keyboard, and is mostly used to create some shortcut operations.
event.shiftKey
Function: Detect whether the Shift key is pressed when the event occurs.
Syntax: event.shiftKey
Value: true | false
Description:
The shiftKey attribute is true to indicate that the Shift key was pressed and held when the event occurred, and false to indicate that the Shift key was not pressed.
The shiftKey attribute can be used in combination with the mouse or keyboard, and is mostly used to create some shortcut operations.
Example 1
Example of combination operation.
If you hold down the Alt key and click on the text box above, you can select the text in the text box.
Example 2
Example of combination operation.
Use the "Ctrl Del" key combination to clear the contents of the text box above. (The text box must be focused first. This example only applies to IE browser.)
Example 3
Combination operation example.
Hold the "Shift" key and click on the color block above with the mouse to change the color of the color block