manifest contains:
“commands”: {
“one”: {
“suggested_key”: {
“default”: “Ctrl+Shift+A”,
“mac”: “Command+Shift+A”
},
“description”: “run shortkey one”
},
“two”: {
“suggested_key”: {
“default”: “Ctrl+Shift+B”,
“mac”: “Command+Shift+B”
},
“description”: “run shortkey two”
},
“three”: {
“suggested_key”: {
“default”: “Ctrl+Shift+C”,
“mac”: “Command+Shift+C”
},
“description”: “run shortkey three”
}
In background script:
chrome.commands.onCommand.addListener(function(cmd) {
console.log("onCommand.addListener " + typeof shortcuts + " JSON " + JSON.stringify(shortcuts) );
if (JSON.stringify(shortcuts) === "{}") {
console.log("shortcuts undefined");
storage.area.get("shortcuts", function(items){
shortcuts = JSON.parse(items["shortcuts"]);
console.log("retrieved shortcuts from storage " + items["shortcuts"] + " cmd: " + cmd );
//console.log(items["shortcuts"]);
//parse_shortcuts(request, shortcuts);
runShortCut(cmd);
});
} else {
runShortCut(cmd);
}
});
However Ctrl+Shift+A does open the extensions page and does not run the code associate with the command in the manisfest in background.js.
How can I associate these and have my shortcut definition working ?