Reputation: 203
I'm trying to make an extension and which uses chrome.contextMenu
. I create a contextMenu element and it works fine, but now I'm wondering if it is possible to add a keyboard shortcut to my element? I've looked through the documentation but could not find anything. Thanks!
Upvotes: 11
Views: 5290
Reputation: 683
One workaround is you can create commands and assign shortcut keys. You can make the context menu item and the command trigger the same functionality.
https://developer.chrome.com/docs/extensions/reference/commands/
Upvotes: 1
Reputation: 2253
Sadly, no. There is an open feature request for it from 2012.
Issue 142840 in chromium: Add "shortcut" property to chrome.contextMenus API
Reported by [email protected], Aug 15, 2012
For native-like experience it should be possible to specify shortcut text for each menu item. E.g. if you create "Copy" menu item then there should be also "Ctrl+C" shortcut text shown next to it.
Proposed API:
chrome.contextMenus.create({ title: 'Copy', shortcut: 'Ctrl+C', id: 'copy', contexts: ['all'] });
also see How can I display keyboard shortcuts to the context menu options created by my chrome extension?
I would also love to see a way to underline one of the letters in a custom context menu listing for ALT access but that appears to also be unsupported.
Upvotes: 6