Mapping VsCode bindings to work with e.keyCode | Ubuntu

46 Views Asked by At

Recently I bought new Wireless Keyboard (Endorfy Thock) and where it works just fine while plugged by cable, the function keys (F1, F2, ..., F12) are working weirdly while keyboard is working in wireless mode

Issue

Using showkey and xev I was able to identify the differences in keybindings between my Laptop Keyboard and my Wireless keyboard. The functionality and the keyCodes were different for my Wireless Keyboard, but with the usage of xmodmap command I'm able to bind proper functionalities to new keyCodes from my wireless keyboard

After this step, keyboard was working fine, but I found some issues in VSCode

VSCode issue

I found out that the Functional Keys are not working properly in VSCode. In next steps I will focus on F3 that is used for highlighting, and searching this highlighted text in current file

F3 was not working, and with the help of this Keybinding Issue article I was able to find the problem. I run the Developer: Toggle Keyboard Shortcuts Troubleshooting and here is the output for F3 key for my Laptop, and my Wireless Keyboard

Laptop F3:

2023-11-26 12:36:42.357 [info] [KeybindingService]: / Soft dispatching keyboard event
2023-11-26 12:36:42.357 [info] [KeybindingService]: | Resolving [F3]
2023-11-26 12:36:42.357 [info] [KeybindingService]: \ From 3 keybinding entries, matched editor.action.nextMatchFindAction, when: editorFocus, source: built-in.
2023-11-26 12:36:42.357 [info] [KeybindingService]: / Received  keydown event - modifiers: [], code: F3, keyCode: 114, key: F3
2023-11-26 12:36:42.358 [info] [KeybindingService]: | Converted keydown event - modifiers: [], code: F3, keyCode: 61 ('F3')
2023-11-26 12:36:42.358 [info] [KeybindingService]: | Resolving [F3]
2023-11-26 12:36:42.358 [info] [KeybindingService]: \ From 3 keybinding entries, matched editor.action.nextMatchFindAction, when: editorFocus, source: built-in.
2023-11-26 12:36:42.358 [info] [KeybindingService]: + Invoking command editor.action.nextMatchFindAction

Wireless Keyboard F3:

2023-11-26 12:37:04.435 [info] [KeybindingService]: / Soft dispatching keyboard event
2023-11-26 12:37:04.436 [info] [KeybindingService]: \ Keyboard event cannot be dispatched
2023-11-26 12:37:04.436 [info] [KeybindingService]: / Received  keydown event - modifiers: [], code: ShowAllWindows, keyCode: 114, key: F3
2023-11-26 12:37:04.436 [info] [KeybindingService]: | Converted keydown event - modifiers: [], code: ShowAllWindows, keyCode: 61 ('F3')
2023-11-26 12:37:04.437 [info] [KeybindingService]: \ Keyboard event cannot be dispatched in keydown phase.

Code is different: F3 for Laptop, ShowAllWindows for Wireless Keyboard


I also tried to bind something for the Wireless Keyboard F3 key, but VScode just see it as "unknown" and when I bind to it doesn't work unknown key binding

In the To sum up section:

On Windows, VS Code dispatches on e.keyCode.

On macOS and Linux, VS Code dispatches on e.code

we can see that VSCode, for Linux, bind the keys using the code, not the keyCode

Questions

I think answering only on from the above questions will be sufficient for my case, but of course knowing answers to all will be super great

  1. In Ubuntu, is it possible to change the code mapping for key?
  2. How to make custom bindings using this ShowAllWindows code? I want it to behave exactly like the F3 key from my Laptop
  3. Can I make VSCode behave in such a way that for some of the bindings it will look at the keyCode, not the code? EDIT: We can make VSCode interpret keyCode instead of code by simply adding "keyboard.dispatch": "keyCode" in our settings.json
0

There are 0 best solutions below