How can I create a VS Code keybinding with three keys (two being non-modifier keys)?

735 Views Asked by At

Trying to bind cursorWordEndRight to alt+;+l so that the command triggers when I press all three simultaneously, - not as a chord - but it highlights red in my Keybindings.json file and says You won't be able to produce this key combination under your current keyboard layout. Key or key sequence (separated by space)

Does VS Code not allow you to have keybinds with two letters? Any way to achieve this?

1

There are 1 best solutions below

0
On

I think you can't, but you could work around it by using chords as long as one of the keys is a modifier. Basically, write every possible sequence of the keys plus the modifier(s) as a binding. Ex.

{
    "key": "alt+b alt+n",
    "command": "cursorUp",
},
{
    "key": "alt+n alt+b",
    "command": "cursorUp",
},

Limitations:

  • It doesn't work when holding the combination down.
  • Note that versions of VS Code before the March 2023 release only support chords with two steps (see https://github.com/microsoft/vscode/pull/175253)
  • It can get unwieldy to define the keybindings the more non-modifier keys you want (quadratic growth).