Execute JS code after pressing the spacebar

后端 未结 5 789
心在旅途
心在旅途 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:45

    In JQuery events are normalised under which event property.

    You can find any key value here eg:spacebar value(32).

    This function may help you.

    $(window).keypress(function(e) {
        if (e.which === 32) {
    
            //Your code goes here
    
        }
    });
    

提交回复
热议问题