Intercept hardware key

I would like to intercept a hardware key (not just use it as a trigger), and I’m not sure how to do that.

Here’s my situation. I have a Das Keyboard that has a volume knob, I can use the volume knob as a trigger and that works quite well, but the problem is that it still turns the volume up / down.

What I would like is to use the ‘Volume Knob up/down’ as a trigger, but suppress the actual key’s action (actually increase/decrease volume).

I don’t want this permanently, but only sometimes.

It cannot be done with Keyboard Maestro.

Something else is translating the knob into volume up/down - perhaps the Das Keyboard has a driver, or perhaps it is simulating hardware volume up/down keystrokes. If the former, then you can perhaps uninstall it. If the latter, I suspect you're out of luck unless Apple has provided a preference somewhere to disable it.

Thanks for getting back to me. I had to get a bit creative, but I was able to figure out a solution.

The volume knob is indeed a ‘hardware’ button. I was able to use Karabiner which can re-map hardware keys.

My use case was a bit more complicated since I only wanted to re-map the buttons sometimes. Interestingly, Karabiner can have ‘profiles’ which can be switch via the command line. So, I set up a profile that re-mapped the increment_volume, decrement_volume keys to right_arrow and left_arrow respectively. Then, in Keyboard Maestro, when I trigger that macro, I switch profiles, then after a specific time (in my case 10 seconds) it reverts back to the previous profile.

Works great!