Search code examples
javascriptgoogle-chromebrowsergoogle-chrome-extensioncrossrider

let user record shortcut in browser extension


Is there a simple way to add this kind of options to browser extension(I'm using the crossrider framework to build cross browser extension)?

Users just need to type the shortcut they want and click the save button

This is a screenshoot from the send to kindle chrome extension

shortcut


Solution

  • With crossrider API you can add keyboard shortcuts

    appAPI.shortcut.add('ALT+CTRL+X', function (event) {
        alert('Alt+Ctrl+X');
    }, {type: 'keydown'});
    

    Edit:

    You can also store the user shortcut preferences on the extension database:

    appAPI.db.set('user_shortcuts', ['Alt+Ctrl+X', 'Ctrl+F12']);