59

I'm trying to figure out why a certain keyboard combination is no longer working.

As an example, Sublime Text 2 ships with a keyboard shortcut for opening the Find/Replace panel:

Command + Option + F

This combo worked fine until I did a clean install of OSX 10.8.5, after which it mysteriously stopped working in Sublime Text.

I know keyboard sequences can be captured by processes other than the frontmost (like by the OS) so I was wondering if there is a way of checking by which process a particular keyboard command was "consumed"?

Mark Fox
  • 735

4 Answers4

64

ShortcutDetective solves your problem. It's free, simple, and to the point.

  • 5
    Fantastic recommendation! This did the trick for me. – D Raymond Apr 05 '19 at 18:10
  • Thank you!!! This saved me from losing my sanity! – Sanjiv Jivan Mar 21 '20 at 23:57
  • 1
    Awesome software, but doesn't seem to work for media keys/shortcuts : [ – CTS_AE May 02 '20 at 02:16
  • Great, this app really helps. – Willis Nov 12 '21 at 08:03
  • 4
    After migrating my Intel MacBook Pro to a new Apple Silicon (M1 Max) Macbook Pro, ShortcutDetective sometimes crashes for me. Is anyone else experiencing this problem? (I used it so often that I would keep it running on my side monitor, but because of this, not anymore. It's still useful for one-off problems, like the OP's question.) – Jonathan Wheeler Dec 20 '21 at 00:32
  • 5
    Yep, I also got a crash on my M1 MacBook Air, but it worked long enough to tell me which app was stealing the keyboard shortcut I was trying to use (it was Logitech Options, and updating it fixed the problem). – Justin Michael Dec 27 '21 at 02:41
  • 5
    It hasn't been updated in years. It crashes every time a shortcut is trigger that's handled by the system (e.g. Shortcuts defined in System Preferences) – huyz Nov 09 '22 at 20:22
  • This doesn't crash for me but it doesn't work at all in Sonoma. Doesn't detect any keypresses at all. Just spins. – Chris Redford Nov 04 '23 at 17:11
25

I don't know any fast and efficient method to find the recipient of a shortcut. But here is a receipe to initiate the hunt:

  1. Close most of your running applications so as to improve the efficiency of the hunt.

  2. Open a Terminal window, and run the following command:

    /usr/bin/sudo opensnoop | more
    

This command will track down every open system call.

  1. Switch to the context where your shortcut is intercepted by an unknown application and type ⌘ cmd+⌥ option+F.

Look for a culprit hint from the file names opened.

  1. while unsuccessfull, add one application, and GOTO 3.
dan
  • 12,177
  • 8
  • 58
  • 136
  • 1
    Nice! If you do this fast enough, you should have a pretty succinct list of processes. I had about 50 lines, half of which were a background process I knew wasn't listening to keyboard presses so I was easily able to filter those out in a text editor. The remaining 20 or so lines recorded 3 other processes, and 75% of them contained my culprit. Thanks so much for sharing, @daniel – Joel Mellon Jan 03 '18 at 17:28
  • 1
    Thanks Daniel. I'd been frustrated for ages that something else was capturing a shortcut meant for one of my applications (and even worse, playing a little ping sound!). ran this, saw maybe 4 apps making calls, one of them was opening "ping.aiff", led me straight to the culprit! – Biglig Feb 26 '19 at 10:35
  • I used this method to find that, frustratingly, Logi Tune is capturing CMD+N. Worked perfectly. – Aaron Sep 21 '21 at 13:49
  • 2
    This worked great, but in macOS 12 it seems that opensnoop isn't working because of System Integrity Protection. – Andrey Mishchenko Apr 06 '22 at 03:21
  • Do you get an error message or did you read this limitation within man opensnoop? – dan Apr 09 '22 at 20:47
  • @dan the message is : probe description syscall::open:entry does not match any probes. System Integrity Protection is on – octern Dec 28 '22 at 18:53
  • @AndreyMishchenko: then I suggest you to temporarily turn off System Integrity Protection. See https://apple.stackexchange.com/questions/208478/how-do-i-disable-system-integrity-protection-sip-aka-rootless-on-macos – dan Jan 01 '23 at 14:32
  • 3
    sudo fs_usage -f filesys can get you there without having to mess with the System Integrity Protection – jgreen Aug 07 '23 at 21:55
  • 1
    @jgreen You should create an answer for this solution. It's infinitely simpler on newer MacOS's. – Joel Mellon Oct 27 '23 at 18:42
  • Both sudo opensnoop and sudo fs_usage -f filesys give me a constant stream of output. How can I narrow this down to finding the app that is intercepting a keyboard shortcut? I'm saavy with the command line, so grep or awk or something would be fine. – Code-Apprentice Jan 05 '24 at 21:14
  • @Code-Apprentice : Since the name you are looking for is the enigma, grep like tools won't be of any use. My method is hit [ctl]+[C] in the shell where opensnoop or fs_usage is running, and scroll back a few lines. – dan Jan 13 '24 at 17:05
  • @dan Thanks for your reply. On the system where I was trying to use opensnoop/fs_usage, the output was so fast that in the time it takes to hit [Ctrl]+[C], there are probably at least a hundred of lines to scroll through and no way for me to know how far back I need to scroll. Which is why I was asking about how to automate this more. – Code-Apprentice Jan 13 '24 at 19:30
  • 1
    @Code-Apprentice : just use | more to slow them down. – dan Jan 14 '24 at 16:03
  • @dan I think that just moves the problem to the other end. Now I have to figure out how far to scroll down from the top instead of up from the bottom. – Code-Apprentice Jan 18 '24 at 06:21
  • This looks cool but I have no idea what this is supposed to be doing or how this is going to help me. It also says: "dtrace: invalid probe specifier" – Alper Jan 24 '24 at 13:46
3

sudo fs_usage -f filesys can get you there without having to mess with the System Integrity Protection.


This was initially a comment on Find which process receives a given keyboard command and was suggested to be added as an answer. Unfortunately, it was a while ago so I don't remember how exactly this was helpful but at least some people found it useful.

agarza
  • 2,274
jgreen
  • 131
1

KeyCue provides visual feedback on the keyboard shortcuts. It can be downloaded as a trial version.

KeyCue from Ergonis

I have it configured so that a double tap and hold on the Command key displays all the currently active shortcuts.

Gilby
  • 10,852
  • 2
    After trying KeyCue, it looks to me like it only shows the keyboard shortcuts associated with menu commands for the current active application. Additionally, it seems to show global hotkeys from Keybaord Maestro and maybe one or two other specific supported applications. Does it show global hotkeys for all applications for you? – Paul Mar 06 '17 at 14:32
  • I find it somewhat mysterious as to what hotkeys are shown for 'other' apps. I think it attempts (but doesn't fully succeed) to show global hotkeys that are relevant to where you are. The User Guide specifically refers to Keyboard Maestro. – Gilby Mar 07 '17 at 05:56