Custom USB Programable Keys With STM32 + AHK

I’ve always had a burning desire to optimize stuff, and this is one of such projects. I don’t like remembering long shortcuts/sequences that I use frequently, or in other words, I don’t like feeling like a monkey doing the same shortcut 500 times (or 5 times to be precise) if there is even a slight chance some script can do it for me.
And it is, here is how.STM32 USB shortcutter buttons

I used an old cheap STM32 development board (STM32L100 Disco), which has USB interface built-in and I’ve transform it to a generic USB HID keyboard, as I’ve done it before. I’ve added a couple of buttons (7) with our free generic library and an UART for the debugging.

Each button press is (after debouncing) sent to a USB host as an almost-unique keyboard shortcut: CTR + SHIFT + F13 (to F19). This shortcut is than handled by AHK script, which can take different actions.

Why is that so GREAT?

  • Such external USB Programmable Keys can be used alongside any standard keyboard. Since user normally can’t press F13 and above keys, collisions are quite impossible.
  • No special drivers are needed except what you already get with STM tools. AHK must be downloaded manually. 
  • Buttons can be on a long cable, for example 10 meters long UTP cable in another room (at the TV sofa or audio recording room).
  • AHK scripts are powerful. You can, as a response to a button press, send simple shortcuts, shortcut sequences, trigger other scripts or take actions based on a specific application. In my case, I use this buttons to trigger VS Code tasks, or control Reaper DAW to stop/restart recording. 
  • You can customize actions it by not even touching the firmware code – just edit AHK script. However, firmware code is relatively simple and you get everything packed on our GitHub.
Get code and example on Damogran Labs GitHub!