Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement keyboard actions to avoid beeps on certain key bindings #2617

Closed
nathansobo opened this issue Aug 27, 2015 · 17 comments
Closed

Implement keyboard actions to avoid beeps on certain key bindings #2617

nathansobo opened this issue Aug 27, 2015 · 17 comments

Comments

@nathansobo
Copy link

@nathansobo nathansobo commented Aug 27, 2015

When ctrl-cmd-down, ctrl-cmd-left, or ctrl-cmd-right are pressed in any Electron (or Chrome) input or textarea, an audible beep occurs. I believe I've tracked this down to the following methods not being implemented in bridged_content_view.mm in the NSResponder Action Messages section starting at line 351.

  • - (void)makeBaseWritingDirectionNatural:(id)sender
  • - (void)makeBaseWritingDirectionRightToLeft:(id)sender
  • - (void)makeBaseWritingDirectionLeftToRight:(id)sender

They do delegate up the responder chain in their implementation of doCommandBySelector on line 579. This leaves me unsure if there's any way to implement these methods via the content API or whether we'll need to add a patch. Either way, it would be great to implement them to avoid the beeping sound when moving lines down in Atom.

Refs atom/atom atom/atom#1669

/cc @zcbenz

@zcbenz
Copy link
Member

@zcbenz zcbenz commented Aug 28, 2015

Awesome, I'll see if we can implement those methods in Electron, and if it doesn't work we can always patch libchromiumcontent.

zcbenz added a commit to electron/libchromiumcontent that referenced this issue Sep 30, 2015
1. Avoid capturing key event to menu.
electron/electron#170

2. Enable accepting first mouse event.
electron/electron#212

3. Enable using transparent window.
electron/electron#949

4. Enable turning off auto hide cursor.
electron/electron#995

5. Disable beeps when pressing certain keys.
electron/electron#2617
@zcbenz
Copy link
Member

@zcbenz zcbenz commented Sep 30, 2015

Hmm I have overridden those methods in Chromium and I'm sure they are on the right place since other methods like copy: and paste: are also there, but the beep is still there.

I also tested whether ctrl-cmd-alt-down would cause beep in Atom, and it does. The ctrl-cmd-alt-down maps to makeTextWritingDirectionNatural: and it is implemented in Chromium, so the problem is not we didn't implement the makeBaseWritingDirectionNatural: method, but something else.

I looked into the key handling code of Chromium and tried to comment out different parts of code, however the beep is always there, I'm out of ideas now.

@nathansobo
Copy link
Author

@nathansobo nathansobo commented Sep 30, 2015

That is frustrating. Thanks for trying. I wonder if we could dtrace into the API doing the beeping and figure out what is causing it. It drives me bonkers that this key binding has such a bad experience.

@alexmalik
Copy link

@alexmalik alexmalik commented Jun 1, 2017

Hello,

I would like to open dialogue on this issue again please. I'm open to trying to fix it myself with my limited knowledge but has anyone taken this any further by any chance?

Thanks for the efforts so far! 👍

@hedefalk
Copy link

@hedefalk hedefalk commented Jul 5, 2017

@alexmalik I'm cheering you on from afar! Pretty please, I'd love a fix.

The workaround mentioned on the atom issue here:
atom/atom#1669 (comment)

does not work on my 10.12.5.

@klvs
Copy link

@klvs klvs commented Aug 15, 2017

@hedefalk That workaround didn't work for me on OSX 10.12.5 either but I did learn that you can disable those sounds globally in system prefs -> sound which is fine by me though I'm sure someone wants it.

@patrick-levesque
Copy link

@patrick-levesque patrick-levesque commented Aug 25, 2017

It was really bugging me too and I found a fix...
Just create a shortcut for ctrl-cmd-down in Keyboard/Shortcuts and disable it afterward.
No more whump sound for me in Atom! 😎
On macOS Sierra 10.12.6 with Atom 1.19.3.

whump_fix

@karlhorky
Copy link

@karlhorky karlhorky commented Aug 25, 2017

@paralel-github tried it, but didn't help. Tried restarting Atom to make sure. Sound is still there though.

@patrick-levesque
Copy link

@patrick-levesque patrick-levesque commented Aug 25, 2017

@karlhorky You're right... when I quit Atom, it doesn't work anymore. 😳

But I've figured out why it did work for me and here's the sequence you need to do. Will require to repeat steps each time you restart Atom. This is not the perfect fix but it works as long as you don't quit Atom.

  1. Quit Atom

  2. Open Keyboard/Shortcuts

  3. Enable the shortcut you've assigned crtl-cmd-down

  4. Quit Keyboard/Shortcuts

  5. Open Atom

  6. Open Keyboard/Shortcuts again

  7. Disable the shortcut

  8. Quit Keyboard/Shortcuts

Then it works!

@karlhorky
Copy link

@karlhorky karlhorky commented Aug 25, 2017

Heh, yep, like that it works! Good find 😄

@mikedpad
Copy link

@mikedpad mikedpad commented Sep 10, 2017

@paralel-github Thanks for that temporary solution. My sanity thanks you! 😄

@jstr
Copy link

@jstr jstr commented Apr 12, 2018

For anyone still frustrated by this I've found the fix described here: atom/atom#1669 (comment) does work but requires a restart to take effect.

@codebytere
Copy link
Member

@codebytere codebytere commented Sep 23, 2018

Given that this is likely a problem upstream in Chromium, and that this isn't currently on our roadmap, i'm going to go ahead and label this a wontfix. However, should someone determine a workable solution we would be very open to accepting a PR!

@hanguokai
Copy link

@hanguokai hanguokai commented Jan 8, 2019

I reported this issue to Chromium on Dec 19, 2018 , and they confirmed it now. To vote up and follow it, Star this issue.

@sentience
Copy link

@sentience sentience commented Jan 7, 2020

Here's a work-around, which I've also posted to @hanguokai's Chromium issue (#2617 (comment)):

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.

DefaultKeyBinding.dict.zip

Once you have created this file, restart any applications where you want to use these keystrokes (or just reboot your system), and you should find that the system beeps are gone. I have successfully applied this tweak on macOS Catalina (10.15.2) to use the default keyboard shortcuts for the “View: Move Editor into Next Group” and “View: Move Editor into Previous Group” commands without hearing system beeps each time.

@Stakker
Copy link

@Stakker Stakker commented Feb 5, 2020

Ahh thank you for the fix. This was driving me crazy :-)

@cpkenn09y
Copy link

@cpkenn09y cpkenn09y commented Aug 21, 2020

same the error sounds were so annoying. Thanks for the fix @sentience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests