0

I'm trying to use Google's commands API to add hotkeys to my extension but I cannot get anything to print to the console. All the Stack Overflow answers say to check the hotkeys page found in the bottom right of the extensions page. I've checked this and my hotkey is set like it's supposed to be.

Manifest.json

{
    "manifest_version": 2,
    ...
    "background": {
        "scripts": ["background.js"]
    },

    "commands": {
        "move_tab_up": {
            "suggested_key": {
                "default": "Ctrl+Shift+K"
        },
        "description": "move tab up one window"
    }
}

Background.js

chrome.commands.onCommand.addListener(function(command) {
    console.log("I am a stupid script.", command);
});
Makyen
  • 31,849
  • 12
  • 86
  • 121
Ripread
  • 330
  • 2
  • 10
  • Are you checking the extension's console? – Daniel Herr Sep 13 '17 at 02:37
  • 1
    What *exactly* is shown in the [various appropriate consoles for your extension](https://stackoverflow.com/a/38920982/3773011) when you load and execute your extension? – Makyen Sep 13 '17 at 06:57
  • read this https://stackoverflow.com/questions/20721938/chrome-extension-commands-keyboard-shortcuts-not-working and https://stackoverflow.com/a/18559164/2724125 – Amit G Sep 13 '17 at 08:26
  • Thanks for the link @Makyen, I didn't realize the background console was separate from the rest! – Ripread Sep 13 '17 at 14:37

1 Answers1

1

Turns out I just wasn't checking the correct console. My extension is running in a background page so I had to specifically use the background page console.

Ripread
  • 330
  • 2
  • 10