VSCode Mac BigSur option key not working as expected
Asked Answered
P

2

8

When I press the [Option+Z] to toggle word wrap it instead prints a character (ˀ)

OS: Mac BigSur
Processor: M1

Keypress event log

[2021-04-21 11:15:15.609] [renderer3] [info] [KeybindingService]: / Received  keydown event - modifiers: [alt], code: AltLeft, keyCode: 18, key: Alt
[2021-04-21 11:15:15.609] [renderer3] [info] [KeybindingService]: | Converted keydown event - modifiers: [alt], code: AltLeft, keyCode: 6 ('Alt')
[2021-04-21 11:15:15.609] [renderer3] [info] [KeybindingService]: \ Keyboard event cannot be dispatched in keydown phase.
[2021-04-21 11:15:15.978] [renderer3] [info] [KeybindingService]: + Storing single modifier for possible chord alt.
[2021-04-21 11:15:16.283] [renderer3] [info] [KeybindingService]: + Clearing single modifier due to 300ms elapsed.
Parthenopaeus answered 21/4, 2021 at 5:53 Comment(2)
I also had several problems for example with formatting shortcut on apple m1. I had to change the shortcut to make it work. e.g. If I change opt+shift+w for wrapping it works.Roye
I also tried Vscode solution of using "keyboard.dispatch": "keyCode" but this also did not work for meRoye
G
19

Try changing the Keyboard Layout.

  • Goto System Preferences > Keyboard > Input Sources.
  • Add the English > ABC Source
  • Remove the existing source that is there. (In my case it was ABC India which contained that special character ˀ for Option+z key combination, the ABC input source will replace that with Ω, which somehow works with VS Code to trigger the special actions instead of inserting that as text)

Finally the input sources should look like this: Keyboard Settings Window

Gas answered 11/8, 2021 at 4:2 Comment(0)
B
0

This answer explains how to completely prevent Option+key from producing special characters, allowing you to use these combinations for shortcuts in VS Code and various other editors.

In short:

  1. Download this QWERTY keyboard layout file (or generate one yourself using the instructions in the linked answer).
  2. Move it to ~/Library/Keyboard Layouts/
  3. Go to System Settings > Keyboard > Text Input > Input Sources > Edit.
  4. Click + in the bottom left, scroll to the bottom of the list on the left and select Others then select QWERTY no option and click Add.
  5. Either delete your existing layout (probably called U.S.) or just switch to the QWERTY no option layout using the input-source select in the menu bar.
Bistro answered 30/6, 2023 at 19:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.