35

When I press commandH, the current window is hidden. I'd like to disable this shortcut, because I'm using it in another application.

I opened System Preferences -> Hardware -> Keyboard -> Keyboard Shortcuts -> Application Shortcuts -> All Applications

I tried adding "No Action" as MenuTitle and commandH as KeyboardShortcut (see screenshot below).

screenshot

But this doesn't work.

What am I doing wrong?

Edit: What solved my problem was assigning shortcut commandOptionShiftH to actions like "Hide Eclipse". Since I never press this key combination, this action never gets executed.

2
  • That won't override an existing command. As every app has a different command for Hide, e.g., Hide Safari, Hide TextEdit, etc., you can't do it that way either. You'll need something like Karabiner or BetterTouchTool
    – Tetsujin
    Feb 21, 2016 at 13:47
  • Your Edit answer worked for me. Sure doesn't affect all apps but this is the easiest way forward thanks. Oct 26, 2022 at 1:17

5 Answers 5

34

Adding an answer based on the Edit: above as it took me a while to figure this out.

If you want to disable the -h shortcut you have to do it per-app.

First open the app, and confirm from the preferences what text option the shortcut is mapped to.

Using Kitty.app as an example, for me it's Hide kitty.

Original Kitty Preferences Screenshot

Then you open System Preferences and go to Keyboard -> Shortcuts -> App Shortcuts and then click +.

Limit it to the relevant app, enter Hide <yourappname> (e.g. Hide kitty in my case), and pick an obscure key combination. I use the section symbol because it's not in my default layout so I won't type it by mistake.

System Preferences Screenshot

Now when you click on the Application's menu, you should see your new shortcut has been set, and -h will no longer hide that application.

Kitty Menu after changing the shortcut

Unfortunately there doesn't seem to be a way to do this for all apps.

See also this MacOS User Guide page.

7
  • This might be obvious, but how are you supposed to actually type the section symbol into the shortcut field? You can't use option+6 because it'll just map the shortcut to that combination. Nov 1, 2018 at 19:18
  • @tay It was possible for me to make that combination on my UK layout keyboard, it might not work for you
    – gib
    Nov 5, 2018 at 14:48
  • @taylorthurlow you can just choose any shortcut you won't accidentally press (e.g. Cmd-Control-Option-Shift-). It can also be done via the command line.
    – gib
    Nov 5, 2018 at 15:05
  • 6
    Awesome. Ironically, I was trying to disable that precisely for kitty
    – Cristian
    Mar 12, 2019 at 1:15
  • this is brilliant. May 6, 2020 at 19:37
14

Adding yet another option:

If you use the Karabiner app (extremely useful in its own right), there is a "Complex Modification" that disables command-h window hiding. Install the app and see the listing: Prevent unintended command-h hide window on this page.

2
  • 2
    this removes the combination all-together, meaning you can't use the combination as a hotkey anywhere else
    – Jose V
    Dec 20, 2021 at 16:55
  • This is the best option for me. Thank you Luke!
    – akawaguc
    Apr 7 at 7:05
1

The (very non-ideal, but functional) way that I solved this problem is to use Alfred to define a global hotkey mapping CommandH to nothing. You could use any app capable of defining global hotkeys to do this (ex. BetterTouchTool or KeyboardMaestro).

Here's the Alfred workflow that I used: My Alfred Workflow, which just registers global hotkeys for CMD-H and CMD-SHIFT-H and does nothing with them

1

If you don't want to use 3rd party applications, try the following sh command:

app="IntelliJ IDEA" # rename me
bundle=$(lsappinfo info -only bundleID "${app}" | cut -d '"' -f4)
defaults write "${bundle}" NSUserKeyEquivalents -dict-add "Hide ${app}" nil

Make sure to rename the app with yours, and restart the app after running it.

1
  • The value nil gets interpreted as N. Using '' resets the shortcut to <kbd>⌘</kbd><kbd>H</kbd>.
    – Noel Yap
    Aug 3 at 16:00
0

Overriding keyboard shortcuts Via macOS Terminal

In this example, I change the "Open Viewer" menu option in Apple Photos to "Space", like it used to be pre-2017:


defaults write com.apple.Photos NSUserKeyEquivalents -dict-add "Open Viewer" -string " "

Reset to defaults:

defaults delete com.apple.Photos NSUserKeyEquivalents

Change the global shortcut for "Preferences" to "⌘ + p" (the "-g" option means "Global", and "@\" translates to "⌘"):

defaults write -g NSUserKeyEquivalents -dict-add "Preferences" -string "@\\p"

A word of warning though: Do not paste this into your Terminal window if you don't feel comfortable with altering the default settings of macOS apps, or if you don't fully understand what it means.

2
  • The question asked about Command-h: can you show that here? Aug 14, 2020 at 12:18
  • defaults write -g NSUserKeyEquivalents -dict-add "Hide" -string "@\\m"I tried that to replace ⌘+H with ⌘+M it did nothing.
    – tatsu
    Oct 6, 2020 at 12:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .