Execute JS code after pressing the spacebar
There’re couple of ways to do this. I am also including a deprecated one with keyCode (from the original answer) just in case (it still seems to work actually as of 2023). document.body.onkeyup = function(e) { if (e.key == ” ” || e.code == “Space” || e.keyCode == 32 ) { //your code } } … Read more