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').
Add a Keyboard Shortcut to Firefox Extension
I've found it by myself <keyset id="mainKeyset"> <key id="key_convert" key="x" modifiers="accel alt" oncommand="OpenMyAddOn()"/> </keyset> –
Cranage
See also: developer.mozilla.org/en/XUL_Tutorial/Keyboard_Shortcuts –
Scotsman
I've found it by myself
<keyset id="mainKeyset"> <key id="key_convert" key="x" modifiers="accel alt" oncommand="OpenMyAddOn()"/> </keyset>
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
This is the true answer. –
Midwifery
I've found it by myself
<keyset id="mainKeyset"> <key id="key_convert" key="x" modifiers="accel alt" oncommand="OpenMyAddOn()"/> </keyset>
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"
})
]);
© 2022 - 2024 — McMap. All rights reserved.