I need hotkeys Alt + ]
and Alt + [
. I have manifest.json
like:
{
...
"commands": {
"nextTrack": {
"suggested_key": {
"default": "Alt+]"
},
"description": "Next track"
},
"previousTrack": {
"suggested_key": {
"default": "Alt+["
},
"description": "Previous track"
},
"toggle": {
"suggested_key": {
"default": "Alt+P"
},
"description": "Toggle pause"
}
},
...
}
When I enable my extension I get:
Could not load extension from '~/project'.
Invalid value for 'commands[1].default': Alt+].
What is way to use that hotkeys?
Only uppercase letters (A-Z) and digits (0-9) are valid values, as you can see by looking at the source code of the chrome.commands
API.
If you want to use other characters, inject a content script in every page which binds a keydown
event:
document.addEventListener('keydown', function(event) {
if (!event.ctrlKey && event.altKey && event.which === 80/*P*/) {
// Dispatch a custom message, handled by your extension
chrome.runtime.sendMessage('Alt+P');
}
}, true); // <-- True is important
<all_urls>
as a match pattern, it won't work on non http(s) / file / ftp(s) schemes like chrome:
, data:
, chrome-extension:
, about:
or the Chrome Web store.[
character, if the keyboard layout does not support it, or uses a different key code.chrome://extensions/
, scroll to the bottom and click on "Configure commands" to change the extension's shortcut).I suggest to pick a different shortcut, or change the way how your extension is controlled (through a page / browser action popup, for instance).
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