我想使用热键在Firefox上打开扩展程序。但是我该怎么做呢?
答案 0 :(得分:0)
您可以使用命令API
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/commands https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/commands
在manifest.json 中像这样"commands": {
"my-shortcut-was-hit": {
"suggested_key": {
"default": "Ctrl+Shift+Y"
},
"description": "Send a 'my-shortcut-was-hit' event to the background script"
}
}
并在后台脚本中:
browser.commands.onCommand.addListener(function(command) {
if (command == "my-shortcut-was-hit") {
console.log("my shortcut was hit!");
}
});
另见https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/commands/onCommand