Reputation: 223
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').
Upvotes: 12
Views: 6093
Reputation: 1423
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
Upvotes: 9
Reputation: 2718
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"
})
]);
Upvotes: 0
Reputation: 223
I've found it by myself
<keyset id="mainKeyset"> <key id="key_convert" key="x" modifiers="accel alt" oncommand="OpenMyAddOn()"/> </keyset>
Upvotes: 7