|(e.keyCode)); switch (arrows){ case 37: ...
$(document).bind('keyup', function(e) {
arrows=((e.which)||(e.keyCode));
switch (arrows){
case 37:
executeMyfunction();
break;
}
});
I believe you have to unbind the event. I think it should not be executeMyfunction()
, but
or
.keyup
Probably something like this.keyup
You will have to rebind the function on keydown
if you want to use the event again:
被反复调用。keyup
如何防止这种情况发生?keypress
我想 keydown
只有当键被释放时才会触发,但它不工作(这就是为什么我使用了
;
$(document).bind('keydown', function(e) {
arrows=((e.which)||(e.keyCode));
switch (arrows){
case 37:
executeMyfunction();
$(document).unbind('keydown');
break;
}
});
也不工作)。)keyup
$(document).bind('keyup', function(e) {
switch (arrows){
case 37:
$(document).bind('keydown');
break;
}
})
假设我们有以下JQuery代码。$(document).bind('keyup', function(e) { arrows=((e.which)/api.jquery.comunbind)
好吧,你可以随时 退弹 函数的调用。也就是说,如果你想让你的函数在事件短时间内没有被触发后被调用。