Use with Pimoroni Keybow programmable keypad?

Hi! I'd like to use Keyboard Maestro effectively with this device:

It's a Raspberry Pi-based USB keypad that can be easily configured to send any sequence of keystrokes. Using its standard layout, which corresponds to a numeric keypad, if I set up a USB Device Key trigger and press the Keybow key programmed to be a "1", KM shows "Bar Gadget 1 and !" as the key. And, since it's a Device Key, the "1" gets passed along rather than eaten.

I would appreciate any recommendations that experienced KM users can provide regarding how I should program this keypad to be most useful with KM. What does "Bar Gadget" mean here? Should I use "USB Device Key Trigger" or "USB Device Trigger"? And what keystrokes should I have the Keybow send to minimize (or, ideally, eliminate) the possibility of collisions with keystrokes that might be used by other applications? Thanks in advance for any advice!

I'm just an average KM user here but I have a decent track record of giving decent advice.

The article you cited says that it "uses the Zero's USB HID gadget mode so that it appears as a real keyboard when plugged into your computer with the included USB cable". To me that implies that Keyboard Maestro won't even know it's a Raspberry Pi. It's just a USB keyboard (or HID device) from KMs perspective. So there is nothing special you have to do.

You asked if you should use "USB Device Key Trigger" or "USB Device Trigger"? There are people here who know more about me that this and can explain what those options can do for you but my answer would be use neither - you can just use a hotkey trigger. From the wiki page trigger:USB Device Key [Keyboard Maestro Wiki] it explains the difference as follows:

Unlike hot key triggers, [with the USB Device Key trigger] the pressed key is not removed or affected in any way. This trigger watches input devices at a low level, but it does not affect them, so any key presses continue to have their normal operation as well as triggering the macro. This is fine for modifiers, unused mouse buttons, programable keyboards and other unused buttons, but would likely be problematic for normal keystrokes which will continue to have some other, probably unwanted, affect.

I'm learning here too. It appears the difference between a hot key and USB device key trigger is that one "removes" the key from the active program which would normally receive it and the other does not. I didn't realize that until now.

Hi, Sleepy, and thanks for the help! Yes, the Keybow does appear to the Mac like a regular USB keyboard, so there's nothing particularly special to be done with it -- except to define the keystrokes that each key sends. I'm trying to figure out if there's some key combination (or sequence of keys) that would be recognizable to KM, but highly unlikely to be used by any other software, so as to avoid collisions. I'm also wondering why KM shows "Bar Gadget 1 and !" when I press a key from that keypad... odd! Maybe "Bar Gadget" refers to the touch bar...?

I have no idea what a "Bar Gadget" is. I'm guessing it's a string coming from the Raspberry keypad. You have a MacBook with a Touch Bar? I'm guessing here, but I don't think it refers to that. We can ask an expert here for help but my gut is telling me the word "Bar Gadget" is originating from the Pi when it connects as a USB device. Perhaps you can go into "About this Mac" and "System Report" and see if you can see "Bar Gadget" under Hardware/USB. That would prove my theory if it's there.

I'm also talking a little over my head here, but I also wish to point out that USB device "keys" do not correspond to ASCII "characters". I think the former are called "Scan Codes" which is why they don't distinguish, for example, between lowercase and uppercase letters. For more info: https://en.wikipedia.org/wiki/USB_human_interface_device_class

So as long as you pick (or its defaults are set to) "scan codes" for your Pi that don't correspond to scan codes from your keyboard and mouse, you should be fine. And I'm comfortable in guessing that the default scan codes do NOT overlap with standard keyboards, and probably not mice either. (But if they do, the Pi will let you change the scan codes generated.) Otherwise the builders of your device are idiots, and I don't think they are.

I think you get KM to "read" the scan code by creating a hotkey trigger, clicking in the "simulate keystroke box" then clicking on the device's key. As long as the device's keys use scan codes that aren't duplicating your keyboard, you should be fine. You will be able to see the name in the box and that should help you confirm everything is alright.

I'm just an average user and my advice tends to be correct about 80% of the time. The wizards and maestros here can correct me if I'm wrong.

Thanks again for your insightful comments -- I'm feeling like you're underestimating your skills here!

I figured out what "Bar Gadget" means, and it's pretty funny. You were right that it's a device identifier string coming from the Keybow; the USB device list does show "Bar Gadget". But why that name? Turns out that the examples for Linux USB device drivers all use "Foo Inc." as the manufacturer identifier and "Bar Gadget" as the name, so it looks like the Keybow folks didn't get around to changing those! And the "1 or !" description aligns with your idea about scan codes -- that key in the upper left of most keyboards is either a "1" or a "!", depending on whether Shift is pressed, so it's reasonable that the key would be called "1 or !".

Having cleared up much of the mystery here, I'm back to figuring out what scan codes would be unused by "normal" keyboards but recognizable to KM. A little more research might find me some options... maybe there are some keys on non-English keyboards that might be suitable for my use.

Again, thanks for your clear and helpful comments. This is what forums are supposed to be like!

For any Keybow users who happen to come across this thread, updating the Keybow to firmware v0.0.4 (or, presumably, later) changes the manufacturer and device names to "Pimoroni" and "Keybow" respectively, and I see "Keybow" when pressing a key from there during KM configuration. Still looking for some "white space" keycode combinations.

Thanks for your nice compliments, and I'm glad you are getting solutions.

To be perfectly honest, I intentionally (perhaps facetiously) underestimate myself. It makes it easier in those cases when I'm wrong. When I said I was right 80% of the time, that wasn't facetious, that's my true average in life. And it's not hard to be wrong when you argue with the wizards and maestros on this forum.

The USB Device Key trigger does not eat the keystroke.

So either use a Hot Key trigger (which will be the same on the normal keyboard as on this device, since hot key triggers do not pay attention to different devices), or use the USB Device Key trigger, which can detect the different devices, but the keystroke is not eaten.

If you can adjust the firmware on the keyboard, adjust it to produce key codes that are ignored by OS X. I would imagine pretty much any key code that is not used would work - if key codes are 2-byte numbers, then probably any key code about 256 would work.

Or just have the device not claim to be a keyboard. Keyboard Maestro should still detect the buttons.

Thanks, Peter! Yes, the Keybow is fully configurable -- you set up the sequences of keycodes for each key through simple Lua scripts. This makes it really flexible and, I think, well suited to use with KM. I'll find some open keycodes and experiment.

I suspect that it'll be better to use the hot key trigger rather than the USB Device Key trigger, so the codes get "eaten". Seems like unknown codes might well generate a "honk" or other weirdness if they were passed through to an application.

The device does not even need to be configured as a keyboard, in which case the Mac would not even try to interpret the keys.

That's an interesting/insightful explanation. You might have actually heard me saying "Ooooh..." from down under.

You can remap it to mouse buttons 3-30, or mouse keys,clicks or modifiers in Karabiner, then use as a usb device in KM. This way you will have extra keys that will never have a conflict with any other keys.

@jgarbers - did you get this working as expected in the end? and if so please do share how :blush: I am looking at buying a Keybow exactly for this use :smiley:

Hello @peternlewis,
I want to use this method but I can't figure out how to do that.
I'm using a das keyboard as my main "normal" keyboard, and want to use my magic keyboard as a macro station where I can run macros with a single click and no modifiers. the problem is the normal letters of those keys are not "eaten".

this is why I want to try your suggested method, but I need help on how to do that.
How do I make my apple magic keyboard "not claim to be a keyboard"?

Thank you

This can only be done by changing the firmware of the device. Well, there might be some low level OS hack or driver hack that could be done, but I have no idea how to do that.

You cannot generally use a second keyboard as a macro-only keyboard.

Thank you, @peternlewis, for your reply.
I'm not giving up yet.
Hopefully, I'll find some answers following your lead in changing the frameware.

If anyone else has some ideas, I'd love to hear them.

My two ideas are: