The only problem was that the HotKey example code did not support Consumer Keys out of the box. I thought about how to solve this for a bit. I originally tested by hard coding a specific key to be the Consumer Key but wanted more flexibility. In the end I decide to add a forth parameter to the array to determine if it was a consumer key.
For example instead of:
Code: Select all
# COLOR LABEL KEY SEQUENCE
(0xA50000, 'Copy', [Keycode.COMMAND, c]), # Copy
Code: Select all
from adafruit_hid.keycode import Keycode # REQUIRED if using Keycode.* values
from adafruit_hid.consumer_control import ConsumerControl # REQUIRED if using ConsumerControlCode.* values
from adafruit_hid.consumer_control_code import ConsumerControlCode # REQUIRED if using ConsumerControlCode.* values
# COLOR LABEL KEY SEQUENCE CONSUMER CONTROL
(0xA50000, 'Mute', [Keycode.COMMAND, c], False), # Copy
(0xA50000, 'Play', [ConsumerControlCode.PLAY_PAUSE], True), # Play/Pause
Code: Select all
SEQUENCE = APPS[APP_INDEX].macros[KEY_NUMBER][2]
CONSUMER_KEY = APPS[APP_INDEX].macros[KEY_NUMBER][3]
if PRESSED:
if KEY_NUMBER < 12: # No pixel for encoder button
MACROPAD.pixels[KEY_NUMBER] = 0xECEBE6
MACROPAD.pixels.show()
for item in SEQUENCE:
# If the fouth array value is set to true, 1 or True then send composer key.
if CONSUMER_KEY:
MACROPAD.consumer_control.send(item)
if isinstance(item, int):
if item >= 0:
MACROPAD.keyboard.press(item)
else:
MACROPAD.keyboard.release(item)
else:
MACROPAD.keyboard_layout.write(item)
else:
...
https://gist.github.com/BrookeDot/32ff2 ... 3848bf02f9
Happy to create a PR upstream is this is helpful to others, and of course always open to feedback on other idea or if there's a different approach you may take.