1
第一次按键后有轻微暂停。 这里的日志:第一次按键后暂停
[00.000ms] keypress -- first keypress [496.00ms] keypress -- second keypress after 496 ms [39.000ms] keypress -- every other keypress after about 20-40 ms. [41.000ms] keypress [21.000ms] keypress [39.000ms] keypress ...
所以这是一个第一次按键之后半秒钟的停顿,剩下的就是后20-40毫秒解雇。
这就是抓住按键代码:
// If we're using the webkit engine, capture the keydowns
if(navigator.userAgent.indexOf("WebKit") != -1){
window.onkeydown = onKeyPress;
} else{
// If we're using gecko, capture the keypress
if(navigator.userAgent.indexOf("Gecko") != -1){
window.onkeypress = onKeyPress;
}
}
的onkeypress事件函数执行的第一件事是调试输出(从上面的日志中的一个)
有谁知道为什么暂停在那里? 就像在Windows或Linux上那样; Firefox或Chrome。