I'm developing a Firefox Extension. I added a new item to the "Tools" Menu to open my extension, but I would like to add a keyboard shortcut to open my extension (something like 'control + alt + x').
Asked
Active
Viewed 5,178 times
11

kjones
- 1,339
- 1
- 13
- 28

Dante López
- 213
- 3
- 10
-
I've found it by myself
-
See also: https://developer.mozilla.org/en/XUL_Tutorial/Keyboard_Shortcuts – Wladimir Palant Dec 22 '11 at 05:45
3 Answers
8
The commands
key is a good way to do this these days; for instance to toggle the main extension pop up (known as the browser_action
), use the following in manifest.json
:
"commands": {
"_execute_browser_action": {
"suggested_key": {
"default": "Ctrl+Shift+Y"
}
}
}
This also exposes an entry in the Add-ons Manager -> Manage Extension Shortcuts settings area where the user can re-map the keyboard shortcut.
Read more on the documentation page: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/commands

kjones
- 1,339
- 1
- 13
- 28
7
I've found it by myself
<keyset id="mainKeyset"> <key id="key_convert" key="x" modifiers="accel alt" oncommand="OpenMyAddOn()"/> </keyset>

Dante López
- 213
- 3
- 10
0
If you need to add shortcut key to Firefox own menu to execute addon action, then you need to edit
extension\content\firebug\firefox\browserMenu.js
and add accesskey:
// Firefox page context menu
$menupopupOverlay(doc, $(doc, "contentAreaContextMenu"), [
$menuseparator(doc),
$menuitem(doc,{
id: "menu_ext",
....
accesskey: "s"
})
]);

Arunas Bartisius
- 1,879
- 22
- 23