禁用firefox插件中的热键 [英] Disabling hotkeys in firefox addon
问题描述
如果你的插件browser.xul的一个覆盖,处理keypress事件的替代方法是在load处理程序中使用脚本从浏览器的XUL文档中移除相关元素,如下所示:
var key = document.getElementById(key_openDownloads);
key.parentNode.removeChild(key);
在不明显的情况下,这将删除打开下载管理器的热键。你可以在这里看到所有的键: http:/ /mxr.mozilla.org/mozilla2.0/source/browser/base/content/browser-sets.inc 。这适用于Mozilla 2.0(即Firefox 4.0.x)。您可以使用页面顶部的下拉菜单来更改树状结构,但是我不认为这些键或ID会经常改变。
根据您的使用情况情况下,这可能比捕捉按键更方便。
Is there a way to disable keyboard shortcuts (hotkeys) in a firefox add-on?
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".
这篇关于禁用firefox插件中的热键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!