87,989
社区成员
发帖
与我相关
我的任务
分享
$(element).keydown(function(){
this.bool = true;
setInterval(foo, 10)
}).keyup(function(){
this.bool = false;
});
function foo(){
if(this.bool){
return;
}
}
$(document).keypress(function(e){
var e = e || window.event;
var k = e.which ? e.which : e.keyCode;
if(k == 65 || k == 97) {// a
$('#div').css('top', /[0-9]+/.exec($('#bird').css('top'))*1 +1 );
}else if(k == 83 || k ==115){//s
$('#div').css('top', /[0-9]+/.exec($('#bird').css('top'))*1 -1 );
}
});