开发者

keydown event not fired while mouse dragging in Chrome

开发者 https://www.devze.com 2023-04-03 01:30 出处:网络
I noticed a strange behav开发者_如何学运维ior regarding keydown event in Chrome. I have this simple script (http://jsfiddle.net/xYDbt/1/):

I noticed a strange behav开发者_如何学运维ior 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?


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

Hope you can workaround with that!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号