3

Is there a extension for displaying key input in vscode?

I am moving on to VSCode from Atom. Since atom provided key detect feature natively, I could easily find key conflicts.

Does VSCode have the same feature in it?

1 Answer 1

3

In vscode v1.49 a new method for troubleshooting keybindings is being added:

Troubleshooting keybindings

To troubleshoot keybindings problems, you can now execute the command Developer: Toggle Keyboard Shortcuts Troubleshooting. This will activate logging of dispatching keyboard shortcuts and will open an output panel with the corresponding log file.

Then, if you press your desired keybinding, you can check what VS Code detects and what command is invoked.

e.g. Pressing cmd+/ in a code editor, on a macbook:

[KeybindingService]: / Received keydown event - modifiers: [meta], code: MetaLeft, keyCode: 91, key: Meta

[KeybindingService]: | Converted keydown event - modifiers: [meta], code: MetaLeft, keyCode: 57 ('Meta')

[KeybindingService]: \ Keyboard event cannot be dispatched.

[KeybindingService]: / Received keydown event - modifiers: [meta], code: Slash, keyCode: 191, key: / [KeybindingService]: | Converted keydown event - modifiers: [meta], code: Slash, keyCode: 85 ('/')

[KeybindingService]: | Resolving meta+[Slash]

[KeybindingService]: \ From 2 keybinding entries, matched editor.action.commentLine, when: editorTextFocus && !editorReadonly, source: built-in.

The first keydown event is for the MetaLeft key (cmd) and cannot be dispatched.

The second keydown event is for the Slash key (/) and is dispatched as meta+[Slash]. There were two keybinding entries mapped from meta+[Slash] and the one that matched was for the command editor.action.commentLine, had the when condition editorTextFocus && !editorReadonly and was a built in keybinding entry.

https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_49.md#troubleshooting-keybindings


You can find key conflicts on a per command basis. See detecting key binding conflicts.

The Keyboard Shortcuts editor has a context menu command Show Conflicts, which will filter the keybindings based on a keyboard shortcut to display conflicts.

from vscode docs: key binding conflicts

Pick a command with the keybinding you think is overloaded and you can see if multiple commands are defined, the source of the keybindings and when they are active.

from vscode docs: key binding conflicts

There is also a command that can show the conflicts as well:

"command": "keybindings.editor.showConflicts"

which could be bound to a keybinding instead of invoking the context menu and selecting "Show Conflicts".

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the answer. But I need to see what command is called in a dynamic view. In Atom's input detection, you can see what command the key input calls for every step of your inputs. With this feature, I can see what command is called among the candidate commands.
Not sure I understand... Do you mean if your candidate keybinding is Ctrl-C Ctrl-K you want to first see conflicts for Ctrl-C and then filter those down to include the Ctrl-K's? If so, you can just type "CTRL-C" and it will show only those and then add "Ctrl-K" to the end of that to see if there are any more already bound commands. [In the Keyboard Shortcuts search box.]
I mean I want to see which command is called if there are multiple commands mapped to a single keybinding. If command+c is mapped to "copy" and "clear", in some case, "copy" will be called according to the environment, such as Vim extension mode, and in some case, "clear" will be. Atom provides "keybinding resolver" for this purpose.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.