Javascript examples for DOM:Mouse Event
The altKey property returns a Boolean value telling if the "ALT" key was pressed while the mouse event was triggered.
This property is read-only.
The following code shows how to find out whether or not the "ALT" key was pressed when a mouse button is clicked:
<!DOCTYPE html> <html> <body onmousedown="isKeyPressed(event)"> <p>Click somewhere in the document while holding the ALT key.</p> <script> function isKeyPressed(event) {//from w ww .ja v a 2 s . co m if (event.altKey) { console.log("The ALT key was pressed!"); } else { console.log("The ALT key was NOT pressed!"); } } </script> </body> </html>