<!DOCTYPE html>
<html>
<body>

<p>Press a key on the keyboard in the input field to find out if the ALT key was pressed or not.</p>

<input type="text" onkeydown="isKeyPressed(event)">

<p id="demo"></p>

<script>
function isKeyPressed(event) {
    var x = document.getElementById("demo");
    if (event.altKey) {
        x.innerHTML = "The ALT key was pressed!";
    } else {
        x.innerHTML = "The ALT key was NOT pressed!";
    }
}
</script>

</body>
</html>