Answers for "check if any key is pressed javascript"

1

how to see if user clicked key in js

document.addEventListener("keyup", function(event) {
    if (event.keyCode === 13) {
        alert('Enter is pressed!');
    }
});
Posted by: Guest on April-25-2021
1

detect keypress javascript

document.addEventListener("keypress", function onEvent(event) {
    if (event.key === "ArrowLeft") {
        // Move Left
    }
    else if (event.key === "Enter") {
        // Open Menu...
    }
});
Posted by: Guest on June-02-2021

Code answers related to "check if any key is pressed javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language