Open browser popup with shortcut keys

I am developing a Google Chrome extension with a browser popup. When the user clicks on the icon, a pop-up window appears.

Is there a way to open this popup using a keyboard shortcut like CTRL + something?

+4
source share
3 answers

You need to add the "commands" object to your manifest.json , as shown at https://developer.chrome.com/extensions/commands . If the extension popup is a "browser_action" popup (indicated by the "browser_action" key in your manifest.json ), you will need the command "_execute_browser_action" ; for the "page_action" you will need the "_execute_page_action" . An example manifest.json using the first is as follows:

 { "manifest_version": 2, "name": "Example Extension", "description": "La la la", "version": "1.0", "browser_action": { "default_icon": "icon.png", "default_popup": "popup.html" }, "commands": { "_execute_browser_action": { "suggested_key": { "default": "Ctrl+Shift+E", "linux": "Ctrl+Shift+K", "windows": "Alt+Shift+P", "mac": "Alt+Shift+P" } } } } 

Please note that in the docs:

Some Chrome shortcuts (such as window management) always take precedence over extension command shortcuts and cannot be overwritten.

As far as I know, there is no canonical list of what these commands are; you just need to experiment with various possible shortcuts suggested until you find one that really works.

+3
source

The chrome.commands api allows the user to associate hotkeys (with your suggestion for a hotkey) that will run commands such as opening a browser action.

+6
source

Sorry, currently impossible. Here is the corresponding function request , you can run it.

+1
source

All Articles