3

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

  • Magic mouse only or also generic mice? – n1000 Jun 27 at 11:17
  • I would like so see the info for any mouse. I don’t have a Magic mouse. – Wayne Bloss Jun 27 at 17:46
0

I'm not sure if it would work correctly, but xinput is included in XQuartz, an implementation of the X Window System for macOS. You can invoke it via Terminal.

  • Not really as I think that goes through another mapping process. – Mark Jun 28 at 12:31
0

Hammerspoon can be scripted to do this.

  • Install Hammerspoon and run it.
  • Open System Preferences, go to Security & 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.)

You must log in to answer this question.

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