Search code examples
google-chromegoogle-chrome-extensionkeyboard

How to force keyboard shortcut on chrome extension at install


I'm trying to implement a chrome extension firing a event with a keyboard shortcut.

The shortcut is declared here :

    "commands":{
    "sample":{
        "suggested_key" : {
            "default":"Ctrl+I",
            "windows":"Ctrl+I"
        },
        "description":"Refresh display",
        "global": true
    }
}

All seems legit, but the problem is that I must set my keyboard shortcut manually in the "Keyboard shortcut" Chrome's menu.

I must force this at extension's installation without setting it manually. This extension will be used my automatsand they can't set this manually.

How can I do that ?


Solution

  • Your description is not valid, and that's why it does not get assigned automatically.

    Regarding global shortcuts from documentation:

    The user is free to designate any shortcut as global using the UI in chrome://extensions \ Keyboard Shortcuts, but the extension developer is limited to specifying only Ctrl+Shift+[0..9] as global shortcuts.

    In short, you can't do that; you need to change the shortcut used or make it non-global.