I am trying to add some keyboard shortcuts to my Chrome extension, specifically to allow the user to use hotkeys to open up a browser action/popup. I've read the documentation, and added the following lines of code to the manifest.json file:
"commands": {
"_execute_browser_action": {
"suggested_key": {
"windows": "Ctrl+Shift+Y",
"mac": "Command+Shift+Y",
"chromeos": "Ctrl+Shift+U",
"linux": "Ctrl+Shift+J"
}
}
}
After adding this, I reloaded my extension in chrome://extensions and proceeded to try out Command+Shift+Y on my Mac and nothing happened. For about 2 hours, I tried setting different hotkey combinations in manifest.json, but none worked. I switched from the dev version of Chrome to the stable version but to no avail. When I went to chrome://extensions and clicked on the 'Keyboard Shortcuts' button at the bottom right, I was able to manually set a hotkey combination and then it worked. But I don't want the user to have to do that manual work.
Keyboard shortcuts could fail to work if you don't press the key combinations at the same time. If you are having difficulties pressing multiple keys at the same time, you should enable Sticky Keys. This Windows 10 feature allows you to press the shortcut keys one after another.
On Chrome 29
you have to navigate to chrome://extensions/
and scroll down to the bottom of the page. On the right side there is a button Keyboard shortcuts
.
Modal dialog pops up with all extensions that have registered some commands
in their manifest file.
But the shortcuts itself are Not set
so the user must set them manually.
As you can see in the source code here: https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/extensions/api/commands/command_service.cc&l=303&sq=package:chromium&rcl=1409677023
The key binding update is only run when OnExtensionWillBeInstalled callback is triggered.
So you need to uninstall and reinstall your local extension to see the default keyboard command appear in : chrome://extensions/configureCommands
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With