用javascript绑定按键,同时防止浏览器快捷键

发布于 2024-08-30 18:21:18 字数 100 浏览 2 评论 0原文

我正在制作一个 javascript 游戏,需要将很多按键绑定到不同的功能。我知道该怎么做,我需要一些帮助来覆盖浏览器的快捷键。换句话说,我想模糊浏览器的热键并将它们转移到我的应用程序。

I'm making a javascript game and need to bind a lot of keys to different functions. This I know how to do, what I need some help on is over-riding the shortcut keys for the browser. in other-words I want to blur hot keys for the browser and divert them to my application.

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

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

发布评论

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

评论(1

烏雲後面有陽光 2024-09-06 18:21:18

我相信,如果您停止事件的传播,那么您将阻止浏览器捕获该事件。

一个例子:

element.onkeyup = function(e) {
   var ev = e || event;
   //do stuff here, probably with ev.keyCode

   return false;
}

I believe that if you stop the propogation of the event, then you will prevent the browser from catching the event.

an example of this:

element.onkeyup = function(e) {
   var ev = e || event;
   //do stuff here, probably with ev.keyCode

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