Detect USB on startup

I currently use Scroll Reverser to have a mouse connected to my laptop without having the natural scrolling direction enabled. I set up a simple pair of macros to start and stop the program whenever the mouse is connected, but I’m at a loss for what to do if the mouse turns out to be connected on startup (possibly before KM even starts). My thought was to use the “at login” or “at engine launch” triggers, but I don’t see an easy way to check whether a device is connected within a macro without scripting it. How might I go about doing that?

Hey Vyas,

You do know that you can turn off “Natural Scrolling” in the System Mouse Preferences - yes?

Keyboard Maestro doesn’t have a means to test for USB devices outside of the USB triggers.

Yes it does – see Peter’s post below.

But it can also be scripted easily enough:

ioreg -p IOUSB -w0


There is a USB Device condition that can test for a device with a specified name.

Grrrf… I even looked in the wiki.

I think I read device condition and my brain translated to device trigger.

Thanks Peter.


@ccstone I was trying out your script solution, but using Peter’s solution seems easier! Thanks for the info, though, your solution did work for me (with a couple additional lines in the script).

I am aware that Natural Scrolling can be turned off, but AFAIK you can’t specify different behavior for mouse and trackpad: changing one automatically changes the other. I want the scroll direction on the trackpad to use Natural Scrolling, but for a mouse scroll wheel it just feels awkward. I could toggle the scroll behavior whenever I plug the mouse in, but that seems like exactly the problem KM is meant to solve.

@peternlewis Thanks, this was exactly what I was looking for.