chrome-extensions-samples
chrome-extensions-samples copied to clipboard
How to add a command that opens the popup via keyboard shortcut?
Hi,
maybe I've overseen something obvious, but I have a hard time finding out how to add a command that toggles the popup of my extension (I want to trigger it on a keyboard shortcut).
There are many chrome extensions which do this, but all I found are still using manifest version 2.
Previously, this seems to have been done automatically though the _execute_browser_action command: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/commands#special_shortcuts
Maybe this could also be added to a simpler example, that introduces how to create the popup?
Best regards,
Ok, I could get it work. My problems were the following:
- The extension needs to be reloaded AND chrome to be restarted before some keyboard shortcuts actually become active
- The new "magic" command for this seems to be
_execute_action
"commands": {
"_execute_action": {
"suggested_key": {
"default": "Ctrl+Period",
"mac": "Command+Period"
}
}
},
How to retrieve the _execute_action key to show it in the option page. Since we can retrieve _execute_browser_action key.
Hi @Fannon! Here is a sample that opens a popup when you click Ctrl/CMD-U. You can modify the keys you wish to bind to within the manifest.json.
@sobujbd I am terribly sorry, but I am not but I do not understand the question. Given the extreme amount of time that has passed since you asked the question, I am going to close this out. Please either open a new issue or stack overflow for any further assistance.
thanks!