Adding multiple selections with Alt-Click instead of Ctrl-Click

I am trying to make CodeMirror 6 work more like VSCode (Monaco). I would like to know how to make clicking add a selection range ONLY if the Alt key is pressed, not the Ctrl / Cmd key. Is there any way to make this work? I have been looking through the reference manual, and I couldn’t find anything to help.

Adding this as an extension should do it:

EditorView.clickAddSelectionRange.of(e => e.altKey)
1 Like

Adding the extension works, however, when using it, you can’t add selection ranges when clicking to the right side of the text.

Below, you can reproduce the error:
https://codemirror.net/try/?c=aW1wb3J0IHtiYXNpY1NldHVwLCBFZGl0b3JWaWV3fSBmcm9tICJjb2RlbWlycm9yIgppbXBvcnQge2phdmFzY3JpcHR9IGZyb20gIkBjb2RlbWlycm9yL2xhbmctamF2YXNjcmlwdCIKCm5ldyBFZGl0b3JWaWV3KHsKICBkb2M6ICJjb25zb2xlLmxvZygnaGVsbG8nKVxuIiwKICBleHRlbnNpb25zOiBbCiAgICBiYXNpY1NldHVwLAogICAgamF2YXNjcmlwdCgpLAogICAgRWRpdG9yVmlldy5jbGlja0FkZHNTZWxlY3Rpb25SYW5nZS5vZihlID0+IGUuYWx0S2V5KQogIF0sCiAgcGFyZW50OiBkb2N1bWVudC5ib2R5Cn0pCg==

basicSetup sets up rectangular selections to use alt. You probably need to remove those from your configuration to use alt for adding selection ranges.

I tried removing the rectangularSelection extension, and it worked. Thank you!