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

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

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

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

</body>
</html>


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