element onkeydown keycode javascript

前端 未结 4 779
傲寒
傲寒 2021-01-14 09:36

I am using this code snippet to add KeyDown event handler to any element in the html form

for(var i=0;i

        
4条回答
  •  盖世英雄少女心
    2021-01-14 10:04

    I used this:

    function check(){
     if (event.keyCode == 32){
      alert("Space is pressed");
     }
    }
    

    and in my body tag: onKeyPress="check()"

提交回复
热议问题