Edit This Code:
<!DOCTYPE html>
<html>
<body onmousedown="isKeyPressed(event)">

<p>Click somewhere in the document. An alert box will tell you if the ALT key was pressed when the onmousedown event occured.</p>

<p><strong>Tip:</strong> Try to press and hold down the ALT key (on your keyboard) before you click in the document.</p>

<script>
function isKeyPressed(event) {
    if (event.altKey) {
        alert("The ALT key was pressed!");
    } else {
        alert("The ALT key was NOT pressed!");
    }
}
</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy