This repository was archived by the owner on Nov 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 168
This repository was archived by the owner on Nov 6, 2019. It is now read-only.
Mac-only keyboard shortcut #438
Copy link
Copy link
Open
Description
I'd like to create a keybinding that only works on macs. Intuitively, I might imagine something like
{
"command": "notebook:create-console",
"selector": ".jp-Notebook:focus",
"macKeys": ["Cmd Shift ."]
}but I think that won't work in the current code (we assume keys is an array throughout the code, and this would make it undefined on non-Mac platforms). I could do this:
{
"command": "notebook:create-console",
"selector": ".jp-Notebook:focus",
"keys": [],
"macKeys": ["Cmd Shift ."]
}but that assumes that the matching function at
phosphor/packages/commands/src/index.ts
Lines 1356 to 1369 in 7a87d35
| function matchSequence(bindKeys: ReadonlyArray<string>, userKeys: ReadonlyArray<string>): SequenceMatch { | |
| if (bindKeys.length < userKeys.length) { | |
| return SequenceMatch.None; | |
| } | |
| for (let i = 0, n = userKeys.length; i < n; ++i) { | |
| if (bindKeys[i] !== userKeys[i]) { | |
| return SequenceMatch.None; | |
| } | |
| } | |
| if (bindKeys.length > userKeys.length) { | |
| return SequenceMatch.Partial; | |
| } | |
| return SequenceMatch.Exact; | |
| } |
Note that I can't do
{
"command": "notebook:create-console",
"selector": ".jp-Notebook:focus",
"keys": ["Cmd Shift ."]
}because this would be translated to "Shift ." on non-mac platforms, which is not intuitive to me. I think the current behavior of ignoring Cmd on non-mac platforms should be changed to invalidating a keybinding if it contains Cmd on a non-mac platform.
Metadata
Metadata
Assignees
Labels
No labels