8

I noticed a strange behavior regarding keydown event in Chrome.

I have this simple script (http://jsfiddle.net/xYDbt/1/):

<div id="x"></div>
<script>
    document.onkeydown = function (e)
    {
        document.getElementById("x").innerHTML += "Hi";
    }
</script>

In Chrome, the event is not fired if the mouse is moved around with left click pressed. This happens only the first time after loading the page. Subsequent keypresses work correctly.

I tested this in FF/Opera/IE and it's not a problem.

Is there a workaround for Chrome?

pimvdb
  • 151,816
  • 78
  • 307
  • 352
mihai
  • 37,072
  • 9
  • 60
  • 86
  • I'm using Chrome with Mac OS X, and I don't seem to have the problem. – Randomblue Sep 04 '11 at 23:32
  • I **can** replicate it on Windows. It doesn't appear limited to the first attempt after page load - the first keydown event will be ignored for each drag session. –  Sep 06 '11 at 12:01

1 Answers1

1

Whilst onkeydown and onkeypress are affected by this bug, it appears onkeyup is not.

Hope you can workaround with that!

  • 1
    Thanks, I got around this by returning false in the onmousedown handler, but this could work just as well. – mihai Sep 08 '11 at 21:01
  • onkeydown, onkeyup are not wokring during drag for me :/ (Version 37.0.2062.120 Ubuntu 14.04 (281580) (64-bit)) – Luckylooke Oct 12 '14 at 13:14