Disabling hotkeys in firefox addon

醉酒当歌 提交于 2019-12-11 04:28:06

问题


Is there a way to disable keyboard shortcuts (hotkeys) in a firefox add-on?


回答1:


If your addon has an overlay for browser.xul, an alternative to handling the "keypress" event is to use script in the "load" handler to remove the relevant elements from the browser XUL document like this:

var key = document.getElementById("key_openDownloads");
key.parentNode.removeChild(key);

In case it's not obvious, this removes the hotkey for opening the download manager. You can see all the keys here: http://mxr.mozilla.org/mozilla2.0/source/browser/base/content/browser-sets.inc. This is for Mozilla 2.0 (i.e. Firefox 4.0.x). You can change the tree using the dropdown at the top of the page, but I don't think these keys or their IDs change very often anyway.

Depending on your use case, this might be more convenient than catching "keypress".



来源:https://stackoverflow.com/questions/6437121/disabling-hotkeys-in-firefox-addon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!