0
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
<script>
   

 var keyPressed = event.originalEvent.code;
                  if(keyPressed == 'KeyZ'){
                      location.replace("https://classroom.google.com");
                  }
        </script>

When clicking the Z key, nothing happens, however when I try it on a different project. The link is avackgames.xyz

Audio Tone
  • 21
  • 2
  • Does this answer your question? [How to find out what character key is pressed?](https://stackoverflow.com/questions/1846599/how-to-find-out-what-character-key-is-pressed) – kmoser May 04 '22 at 02:32

1 Answers1

0

In this case, you should use the 'keydown' event listener.

For more information please visit this website.... (Click here)

This is the JavaScript code you should add to your HTML file code. I hope it's clear and helpful, Thanks!.

<script>
    //Create event listener for 'keydown'
    window.addEventListener('keydown', KeyPressed)
        //Create a function with 'event' parameter
    function KeyPressed(event) {
        //Checking if Z key pressed, For your information, the code '90' is for the Z key.
        if (event.keyCode == 90) {
            //To be sure that the 'Z' key was pressed, let's show an alert message.
            alert('Yeeess, you clicked Z key!')
        }
    }
</script>
vpn
  • 23
  • 6