macOS Making Bell Sound on Moving Line Down in Visual Studio Code

I'm using macOS Mojave (10.14.2) and VSCode (1.31.1).

My issue is that every time I use the "Move Line Down" command using Control + Command + Down arrow, I get the bell sound that signifies some kind of error. However, when I use the "Move Line Up" command using Control + Command + Up arrow, there is no error sound.

It's been like this for as long as I can remember. I even checked the shortcuts to make sure nothing else is mapping to this shortcut, but I couldn't find any other commands mapping to the same shortcut. The strange thing is that when I click on the command from the menu, there is no error. I feel that this points to something but I can't seem to figure out what's causing this.

EDIT: Just realized that this is an open issue and the command in making noise due to it being blocked in Electron


Solution 1:

This appears to be an issue with Chromium (used by Electron, used by VSCode). There's a workaround here: https://github.com/electron/electron/issues/2617#issuecomment-571447707 I'll copy the gist of it here for convenience:

You can establish system-global key bindings for the key combinations ^⌘←, ^⌘↓, and ^⌘→ that are mapped to no operation ("noop"). Simply having these declared as valid keystrokes at the OS level eliminates the system beep that occurs even when a Chromium app accepts and handles the keystroke.

In order to establish this, you need to create a ~/Library/KeyBindings/DefaultKeyBinding.dict – note that you'll probably need to create the directory as well, and that the directory name is plural (Bindings), but the file name is singular (Binding). This should be in your user Library folder, not the /Library folder or the /System/Library folder.

The file should be a text file with these contents:

{
  "^@\UF701" = "noop";
  "^@\UF702" = "noop";
  "^@\UF703" = "noop";
}

^ means Ctrl, @ means Command, and \UF701, \UF702, and \UF703 are the codes for the three arrow keys. There's a nice reference Gist for this file's syntax here: https://gist.github.com/trusktr/1e5e516df4e8032cbc3d I have attached a copy of my file in case that's easier for folks.

Also: don't forget to restart VSCode after adding that file! You have to restart for the changes to take effect.