Mapping a single keypress to a chord

I want to program the Any key to send a specific chord: Shift+Alt+Minus. I’ve found the relevant function in the firmware, and I see how to trigger a single key with kaleidoscope::hid::pressKey, but I’m not sure how to send multiple at once. How might I do this?

1 Like

I think a macro would work; something like the following (warning: untested)

EDIT: I don’t know why I read “shift” as “control” :stuck_out_tongue:

enum macros {
 // this could be whatever you want, just calling it SAM for Shift-Alt-Minus
  MACRO_SAM,
};

const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
  if (macroIndex == MACRO_SAM) {
    return MACRODOWN(D(LeftShift), D(LeftAlt), T(Minus), U(LeftAlt), U(LeftShift));
  }
 return MACRO_NONE;
}

// Then put M(MACRO_SAM) in your keymap at the appropriate place

2 Likes

That did it, thanks. (I had to replace Control with Shift, but otherwise everything went swimmingly.)

1 Like

Oh good! I updated the snippet there so if anyone else stumbles across it they won’t be confused (no idea how I misread shift as control)

Another option is LSHIFT(LALT(Key_Minus)) right in the keymap, or #define KEY_SAM LSHIFT(LALT(Key_Minus)), and use KEY_SAM in the keymap.

This is a slightly underdocumented feature, but you can have keys on the keymap that have LSHIFT, LALT, RALT, LCTRL, LGUI, or any combination of these applied to their normal code. Mind you, this can only be done for keys defined in key_defs_keyboard.h.

6 Likes

Thanks. Though I know it won’t make any difference in the end, is one method faster than the other?

LSHIFT(LALT(Key_Minus)) is a tiny bit faster. My educated guess would be that we’re talking sub-millisecond differences though.

That’s about what I figured. Thanks.

Heh, I’m looking to do “hyper” as my own modifier (shift, ctrl, alt, command - I map this non-conflicting custom super-modifier for my own OS mappings). I took a shot at it, but it’s not compiliing:

LSHIFT(LALT(LGUI(LCTRL())))

I must be close, but need a hint!

I _think: LSHIFT(LALT(LGUI(Key_LeftControl))) or something close to that (I haven’t tested that for compilation.)

All of those LBLAH() things are C preprocessor macros that modify the thing inside them. But you’ve got nothing inside to modify.

https://github.com/keyboardio/Kaleidoscope/blob/master/src/key_defs.h#L78 should help explain it if you have a little bit of C experience.

3 Likes

That did it! Many thanks.

1 Like