Mac generating ∆˚¬ characters instead of executing VSCode shortcuts that involve alt / option key
Asked Answered
R

5

19

Problem
When I type alt+j, I always get the character , even if I've assigned alt+j to a keyboard shortcut within VSCode.

The same is true for any other alphanumeric keys, but non-character-generating keys work fine with alt, like alt+upArrow.

Therefore, I can't use the alt key as a modifier for many keyboard shortcuts.

I realize this is normal MacOS behavior for text input, but I'm wondering:

Question
Can VSCode override / takes-precedence-over the OS, so that I can use the alt key for keyboard shortcuts?

Tried so far
I've searched for settings within VSCode and MacOS, but haven't found anything obvious. I've also edited keybindings.json, to no effect.

Recognize answered 26/3, 2020 at 14:58 Comment(4)
Is How to disable typing special characters when pressing option key in Mac OS X? out of date?Interior
Thanks for that link! I'd rather rely on native Mac or VSCode options than an 3rd-party intermediary, if possible.Recognize
VS Code is a third-party program w.r.t. the Apple ecosystem, so you've stepped on that path already ;)Interior
Ah, by 3rd-party, I literally mean that MacOS is (1), VSCode is (2), and I'd rather not have a (3) to keep track of if this can be done within (1) and (2).Recognize
R
30

Solved this as follows with no complicated keybinding file changes:

⟶ System preferences
⟶ Keyboard
⟶ Input Sources Tab
+ at bottom left
⟶ add and select Unicode Hex Input from panel on right

 ✓  Mac no longer prints anything on alt+letter|number
 ✓  enter unicode characters via alt+[code]
 ✅ Keyboard shortcuts are assignable to alt key!

Recognize answered 28/4, 2020 at 14:22 Comment(6)
Thanks, this worked for me. I was on a Mac which had Input Source as ABC-Lang, I removed ABC-Lang and added ABC, and I was able to use VSCode shortcuts.Sequoia
The unicode hex option does not exist for me.Gelb
I replaced ABC with Unicode Hex Input and everything works fine 👍Annunciator
@Gelb you have to select 'other' in the list of the languagesCode
Worked for me. Had to remove the default "US" from the list tho.Conium
The problem now is that alt + left|right arrow doesn't work either 😅Conium
C
6
"terminal.integrated.macOptionIsMeta": true

Source

Clearing answered 19/4, 2021 at 2:35 Comment(1)
it only works in terminal but not the editorAnnunciator
S
1

If you are using mac and typed 'opt+a/p/9/...' or 'opt+shift+a/q/9..' and then got wired special characters, you find the right place.

I was using Karabiner and struggled to find the perfect solution. Open you 'karabiner.json' config file. Put the following 'Boss Rule' in the last position, if you have own binding keys, remember to put your rules before the following rule. Other apps' shortcuts seem to be override by this last rule unless you set application exception, find more about it here.

The manipulators are evaluated from the top to the bottom and the input event is manipulated only the first matched manipulator.

{
  description: 'disable all option or option+shift keys',
  manipulators: [
    {
      from: {
        any: 'key_code',
        modifiers: {
          mandatory: ['left_option'],
          optional: 'left_shift'
        }
      },
      to: [
        {
          key_code: 'vk_none'
        }
      ],
      type: 'basic'
    }
  ]
}


Save the config file and enjoy!!!

Spam answered 7/6, 2023 at 6:48 Comment(1)
Another option is to exchange your "left_option" and "left_control" using Karabiner and this is the way I am using now. It feels awesome. For shortcuts, I used to set "left_option+j" to move cursor left, but now I set it to "left_control+j". But I am still pressing "left_option" in the keyboardSpam
U
0

Set your keyboard input source to "ABC", not "ABC - Extended" or anything else and it will work as expected.

Steps: System Preferences -> Keyboard -> Input Sources -> + (add an input source) -> Select "ABC"

Ursi answered 26/12, 2023 at 18:3 Comment(0)
A
0

Instead of ABC-India select ABC in System Preferences->Keyboard->System Input - enter image description here

This ✅ solved the issue for me.

Andres answered 16/1 at 20:32 Comment(1)
This is already part of the existing Answers.Lymphangial

© 2022 - 2024 — McMap. All rights reserved.