// You can use window.addEventListener or document.addEventListener window.addEventListener("keydown", function(event) { if (event.key == "key Name"){ // Do Stuff } });