Skip to content
This repository was archived by the owner on Nov 6, 2019. It is now read-only.
This repository was archived by the owner on Nov 6, 2019. It is now read-only.

Mac-only keyboard shortcut #438

@jasongrout

Description

@jasongrout

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

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;
}
is never called with userKeys being an empty list. I think that's valid - are we guaranteed that?

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions