Execute JS code after pressing the spacebar

后端 未结 5 800
心在旅途
心在旅途 2020-12-11 00:21

this is my code in JavaScript:

var changeIdValue =  function(id, value) {
document.getElementById(id).style.height = value;
};

document.getElementById (\"ba         


        
5条回答
  •  不思量自难忘°
    2020-12-11 00:46

    document.body.onkeyup = function(e){
        if(e.keyCode == 32){
            //your code
        }
    }
    

    This will be executed after you hit spacebar.

    JSFiddle.

提交回复
热议问题