X
點擊此處開啟此網站的行動版。

技術支援討論區

How to disable ALT key default behavior from javascript

已張貼

I am writing a canvas-based RPG game. I use keyboard to control the player, including 'press and hold ALT key to highlight items'. Problem - when player is done highlighting and releases the ALT key, top level browser menu pops up, even if I call event.preventDefault(). Question - is there a way I can tell Firefox to not to do that - i know that end user can disable this behavior via about:config flag, but I can't just go and ask every user to do that... (Firefox 73) Thank you!

I am writing a canvas-based RPG game. I use keyboard to control the player, including 'press and hold ALT key to highlight items'. Problem - when player is done highlighting and releases the ALT key, top level browser menu pops up, even if I call event.preventDefault(). Question - is there a way I can tell Firefox to not to do that - i know that end user can disable this behavior via about:config flag, but I can't just go and ask every user to do that... (Firefox 73) Thank you!
引用

額外的系統細節

應用程式

  • User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0

更多資訊

cor-el
  • Top 10 Contributor
  • Moderator
17874 個解決方法 161723 個答案

Alt without other modifiers is used for the accessing the menu bar in the user interface. For access keys on web page is Shift+Alt reserved, so without disabling the Alt key for opening the menu bar via a pref (ui.key.menuAccessKeyFocuses = false), like you probably know, I don't think there is a way to prevent this.

Alt without other modifiers is used for the accessing the menu bar in the user interface. For access keys on web page is Shift+Alt reserved, so without disabling the Alt key for opening the menu bar via a pref (ui.key.menuAccessKeyFocuses = false), like you probably know, I don't think there is a way to prevent this.
這篇文章有幫助嗎?
引用

提出問題者

That is what I was afraid of... For some reason writing games for Firefox is especially hard - a lot of little things like this just keep popping up.. Thanks anyway!

That is what I was afraid of... For some reason writing games for Firefox is especially hard - a lot of little things like this just keep popping up.. Thanks anyway!
這篇文章有幫助嗎?
引用
Roland Tanglao
  • Administrator
78 個解決方法 852 個答案

Hi Serg Nights:

This is a user support focused forum and because of this there aren't many folks who can answer developer questions like your question.

The best place to ask dev questions for games and other web apps is stack overflow: https://stackoverflow.com/questions/tagged/firefox

More details: https://support.mozilla.org/en-US/kb/where-go-developer-support

Cheers!

...Roland

Hi Serg Nights: This is a user support focused forum and because of this there aren't many folks who can answer developer questions like your question. The best place to ask dev questions for games and other web apps is stack overflow: https://stackoverflow.com/questions/tagged/firefox More details: https://support.mozilla.org/en-US/kb/where-go-developer-support Cheers! ...Roland
這篇文章有幫助嗎?
引用
問個問題

如果您還沒有帳號,您必須先 登入您的帳號 來回覆文章。請 開始一個新問題