Utility to identify what mouse buttons are being pressed? Is there a utility for mac to show what mouse buttons are being pressed?

Similar utilities for Windows are: Spy++ and WindowSpy from AutoHotKey.

For Linux I have used: xinput --query-state
Hammerspoon can be scripted to do this.


Install Hammerspoon and run it.
Open System Preferences, go to Security &amp; Privacy and enable Hammerspoon.app under Accessibility.
Click the Hammerspoon menu icon and select Open Config. Your default code/text editor will open to ~/.hammerspoon/init.lua.
Enter something like the following text which uses the Hammerspoon hs.eventtap.new API to listen for events.


detectMouseDown = hs.eventtap.new({ 
  hs.eventtap.event.types.otherMouseDown,
  hs.eventtap.event.types.leftMouseDown,
  hs.eventtap.event.types.rightMouseDown
}, function(e)
  local button = e:getProperty(
      hs.eventtap.event.properties['mouseEventButtonNumber']
  )
  print(string.format("Clicked Mouse Button: %i", button))
end)

detectMouseDown:start()




Save the file.
Click the Hammerspoon menu icon, select Console... and click Reload config on the console window.
Now, whenever you click anywhere you'll see a log entry in the Hammerspoon Console!


(So far, this works for any type of touchpad click/tap or external mouse click.)