0
votes

Here's all I'm doing:

$(document).keydown(function(e) {
    e.preventDefault();
    console.debug(e.keyCode, "down");
});
$(document).keyup(function(e) {
    e.preventDefault();
    console.debug(e.keyCode, "up");
});

You can see the problem here: http://jsfiddle.net/pJgyu/32530/

If I hold down a letter key, keydown is fired constantly until I let go. Then keyup fires once. That seems like the correct behavior.

If I hold down an arrow key, keydown and keyup alternate constantly. Why is keyup firing?

I've tried it without the "e.preventDefault();".

Also, after holding an arrow key, SOMETIMES letter keys display the same strange behavior.

2
It works good for me in chrome. - Mateusz Rogulski

2 Answers

2
votes

Your keyboard may be broken. I don't have that issue when I try to replicate it in your jsfiddle.

0
votes

It is not only the keyboard that has to be broken. I had the same issue and spent some time googling and debugging it, and only after a couple of painful hours I remembered about my key mapping software that I use. My AutoHotkey scripts do several things with special keys, such as arrows, and this was the reason for the issue.