How to add multiple keyboard shortcuts to one command in VS Code?

Viewed 453

How can I add multiple keyboard shortcuts to a single command in VS Code?

As an example (from the comments), ctrl + 0 & ctrl + 1 should both do the same command/action. So completely separate shortcuts doing the same command.

1 Answers

Let's say there are 2 bindings to close window like so:

enter image description here

Let's say we want to add one more keybinding like CMD+K, CMD+1. You could do that by right-clicking a command and choosing copy like so:

enter image description here

Then, click on an icon on the top right corner to open keyboard shortcuts JSON. The icon has an curved arrow on a page:

enter image description here

Your user-defined keybindings.JSON will show up. Type this in it:

// Place your key bindings in this file to override the defaults
[
    {
        "key": "cmd+k cmd+1",
        "command": "workbench.action.closeWindow"
    }
]

Save and close.

Now you will see 3 keybindings for the action like so:

enter image description here

Now, try your new keybinding.

Related