-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify the format of Command.shortcut or add a new Command.shortcutKeys property #309
Comments
P.S. This was originally filed at #300 but split off. Relevant thread: Fragment by @Rob--W at #300 (comment) :
Reply by @hanguokai at #300 (comment) :
Reply by @Rob--W at #300 (comment) :
|
I think the problem is there is no definition of the format for this property. If it is only used for informational purposes, then I suggest add a new property like Solution 2. |
For what it's worth, I've seen the following returned from this API:
|
My proposal would be to split the concerns here being:
For the first we can keep using the For updating the commands it would thus make more sense to be using the |
Use Case
Developers can use
browser.commands.getAll()
to display a shortcuts table for users.Command.shortcut
is a string, for example"Ctrl+Shift+U"
. I want to parse this string and style it in HTML, for example:shortcut.split('+')
get each key string, then transform them to<kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>U</kbd>
in HTML and use css to stylekbd
element.The Problem
There is no document to define the format of
Command.shortcut
(don't confused with "suggested_key" in manifest), and it is different format cross platforms in Chrome, I don't test it in Firefox.For example, the shortcut Ctrl+F. On Chrome OS , the value is
"Ctrl+F"
(PS: I don't have computers to test it on Windows and Linux). But on macOS, it is"^F"
(no plus sign and use ^ for Ctrl). The format is different!Solution
There are two solutions for this problem.
Solution 1: Unify the format of Command.shortcut
I understand, on macOS, it is usually use
⌃
for Ctrl,⌥
for Opt and⇧
for Shift. I don't want to unify the key string. I want to unify the format of key combination. For example, on all platforms, use the format ofkey1+key2
orkey1+key2+key3
, and no space between key and +. Note: the key+
can't be use in shortcut, so it is safe as the separator between keys.Solution 2: Add a new Command.shortcutKeys property
Thus, developers can use this property to format shortcut in page, like below:
The text was updated successfully, but these errors were encountered: