When the mouse is moving in a browser, ideally the mousemove
event should fire every frame. However, if a key is pressed or released (or repeated), the mousemove
event stops firing for a frame or two. To test this behavior, you can use the code snippet below:
t0 = new Date().getTime()
window.onmousemove = function() {
t = new Date().getTime()
if (t-t0 > 20)
console.log(t-t0)
t0 = t
}
Keep your mouse moving and observe the console to see delays of the mousemove
event only when there are key press/release actions.
I have personally tested this on Firefox and Chrome browsers using macOS 10.14.2.
As I am developing a web action game, it is crucial that the mouse position is updated every frame. If anyone has any solutions to address this issue, please let me know.