Reputation: 25028
I was looking at the chrome.commands
API for adding some functionality to m y extension.
Basically what I want to do is to listen for specific key combinations, say CTRLALTS, to display the default popup of my extension.
I understood how that could be included in the manifest. Reading further, I found this:
In your background page, you can bind a handler to each of the commands defined in the manifest (except for '_execute_browser_action' and '_execute_page_action') via onCommand.addListener.
What I understand is that I need to have a background page that listens for these key combinations and takes actions appropriately. All good.
and there is this paragraph, too:
The '_execute_browser_action' and '_execute_page_action' commands are reserved for the action of opening your extension's popups. They won't normally generate events that you can handle. If you need to take action based on your popup opening, consider listening for an 'onDomReady' event inside your popup's code.
The difficulty that remains is :
How do I make the default popup visible? :)
Upvotes: 1
Views: 575
Reputation: 77551
Basically, that remark says "you don't need to (and can't) handle these actions yourself". They will open the popup regardless, and listeners don't get fired.
So, for a minimal example a background page is not needed at all.
In the manifest:
"commands": {
"_execute_browser_action": {
"suggested_key": {
"default": "Ctrl+Alt+S",
}
}
}
And then Ctrl+Alt+S will mimic clicking your browser action.
chrome.browserAction.onClicked
will fire.chrome.commands.onCommand
even will not fire in either case.Upvotes: 3