vscode-which-key
vscode-which-key copied to clipboard
Possible to map arrow keys?
Hello
I have a QMK powered keyboard, meaning I can put arrow keys on a layer and don't need to use hjkl. Since I am using a custom layout, the hjkl keys are no longer on the home row.
I want to be able to map something like spc w right
, where I can navigate windows with the arrow keys. This works in emacs.
Is this possible? I'm not sure how the syntax looks like in the configuration. Hopefully this is something vscode allows you to bind!
Thanks!
It is possible. See use-non-character-keys. As an example, for SPC w <right>
:
- Add the follow bindings to your user's user
keybindings.json
so we can intercept the<right>
key and send it as→
to which key.
{
"key": "right",
"command": "whichkey.triggerKey",
"args": "→",
"when": "whichkeyVisible"
}
- Add the following overrides to your user's
settings.json
so we have a entry that maps toSPC w →
"vspacecode.bindingOverrides": [
{
"keys": "w.→",
"name": "Focus window right",
"type": "command",
"command": "workbench.action.focusNextGroup"
}
]
But I would be a little bit hesitant to add that as the default, because up and down key can select different menu items in the QuickPick menu.
Thank you! I missed that section in the docs. I agree adding it by default might not be ideal - maybe some configuration flag or snippet in the docs would be the best solution.
Thank you for the great plugin! Maybe I will make some doom-flavoured config in the future :eyes:.
I'm having trouble binding the up/down keys.
Simply adding
{
"key": "up",
"command": "whichkey.triggerKey",
"args": "→",
"when": "whichkeyVisible"
},
along with the settings entry you mentioned above does not seem to do anything. I'm aware that I kept the right arrow, but I think that it should just call the "focus window right" binding we defined earlier for the right arrow (which works).
My theory is that vscode does not allow you to bind up/down in the quick pick menu. Maybe https://github.com/microsoft/vscode/issues/98479 is related?
I'm wondering if you have any other workarounds, if I should comment on the linked issue, or if I should make a new issue.
Thanks!
Sorry. I didn't test all the arrow keys. Seems like it is evident by the issue you linked that up/down arrow are special case'd in the QuickInput. See https://github.com/microsoft/vscode/blob/main/src/vs/base/parts/quickinput/browser/quickInput.ts#L724-L741.
I don't see any workaround available unless vscode team changed how they handle those keys. Maybe try commenting on the linked issue to start?
Just a quick note before I comment on the issue (in a few days), I found that commenting out the dom.EventHelper.stop(event, true);
in the code you linked and building from source allowed the extension to override the shortcut while still allowing the key to work to navigate in other contexts.
That's interesting. I guess that's what stopping the dom event which bubbling up to shortcut handling? Anyway that's a very detailed comment on vscode 👍