jq或者js如何能达到键盘组合的事件?
// 上下左右 斜
let time = ''
let a = []
document.onkeydown =(e)=>{
a[e.which] = true // 判断 ☆
time = setTimeout(()=>{
a[37]&& (box.style.left =box.offsetLeft-5+'px')
a[38]&& (box.style.top = box.offsetTop-5+'px')
a[39]&& (box.style.left =box.offsetLeft+5+'px')
a[40]&& (box.style.top = box.offsetTop+5+'px')
},160) =>> 移动速度
}
document.onkeyup =(e)=>{
a[e.which]=false
}
赞1
踩0