增加Javascript鼠标事件

发布于 2024-11-19 13:55:14 字数 111 浏览 2 评论 0原文

我想知道是否有办法提高JS的mousemove事件的采样率。 当我快速穿过窗口时,我只收到大约 10-20 个事件,不足以达到目的 的应用程序,当我慢慢地做时,我可以达到+100;

提前致谢,

I would like to know if is there any way to increase the sample rate of mousemove events of JS.
When I cross the window quickly I only get around 10-20 events, not enough for the purpose
of the app, when I do it slowly I can reach +100;

Thanks in advance,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

阳光的暖冬 2024-11-26 13:55:14

我认为,但也许我错了,mousemove事件的“采样率”不是由javascript决定的,而是由鼠标的采样率决定的。这意味着每当鼠标向浏览器发送事件时,就会触发一个事件(如果鼠标移动了至少一个像素)并且您可以响应它。
采样率较高的鼠标会创建更多事件(并且更精确),而采样率较低的鼠标会创建较少的事件。这就是为什么当你玩《雷神之锤 4》时,鼠标的采样率会影响你的瞄准精度。

所以我不认为这是javascript的问题,你应该让你的应用程序对鼠标生成的事件做出相应的响应。在具有自动瞄准选项的第一人称射击游戏中也可以完成同样的操作。

I think, but maybe i'm wrong, that mousemove events "sample rate" is not determined by javascript, but from the sample rate of your mouse. This means that whenever the mouse sends an event to the browser, an event is fired (if the mouse has moved of at least one pixel) and you can respond to it.
Mouse with higher sample rates create more events (and are more precise), where mouse with lower sample rate create fewer events. This is why when you play quake 4 the sample rate of your mouse affects the precision of your aiming.

So i don't think it's a problem of javascript, and you should have your app respond accordingly to the events generated from the mouse. The same thing is done in first person shooter with the auto aiming option.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文