Using the Chrome commands API in Kiosk Mode

613 views Asked by At

I am writing a Kiosk Mode Chrome App that responds to a keyboard shortcut. The best way I have found to do this uses the Chrome commands API.

manifest.json

  {...,
    "kiosk_enabled": true,
    "kiosk_only": false,
    "commands": {
      "perform-foo": {
        "description": "Performs the Foo action",
        "suggested_key": {
          "default": "Ctrl+Shift+0"
        },
        "global": true
      }
    },
  ...}

As far as I can tell from the documentation, no special permissions are required. I made sure to use a "safe" key combination as per the documentation, and figured I'd specify global for the heck of it.

main.js

chrome.commands.onCommand.addListener(function(command) {
  if (command == 'perform-foo') {
    doFooFunction();
  }
}

This works on my Mac as an unpacked extension, but it does not work when launched in either Single App Kiosk Mode or normal Kiosk Mode under ChromeOS. I've also written a test app that does not operate in kiosk mode. When I check out the keyboard shortcuts in chrome://extensions, the apps seems to have successfully, globally installed the correct key combination.

Are keyboard shortcuts via the commands API enabled for kiosk mode, or CrOS in general? What am I missing here?

1

There are 1 answers

1
Sarah Elan On BEST ANSWER

From the documentation:

On desktop Chrome, Commands can instead have global scope, as of version 35, and will then also work while Chrome does not have focus. NOTE: The exception here is Chrome OS, where global commands are not allowed at the moment.

I have had success using commands in kiosk mode on ChromeOS without the global option.

"commands": {
  "perform-foo": {
    "description": "Performs the Foo action",
    "suggested_key": {
      "default": "Ctrl+Shift+0"
    }
  }
},