Reputation: 64
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?
Upvotes: 3
Views: 3055
Reputation: 182771
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 asmeta+[Slash]
. There were two keybinding entries mapped frommeta+[Slash]
and the one that matched was for the commandeditor.action.commentLine
, had thewhen
conditioneditorTextFocus && !editorReadonly
and was a built in keybinding entry.
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.
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.
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".
Upvotes: 3