Why does only ALT have separate LALT_HELD and RALT_HELD flags?

See this section of key_defs.h:

#define CTRL_HELD         B00000001
#define LALT_HELD         B00000010
#define RALT_HELD         B00000100
#define SHIFT_HELD        B00001000
#define GUI_HELD          B00010000
...
#define LCTRL(k)  ((Key) { k.keyCode, k.flags | CTRL_HELD })
#define LALT(k)   ((Key) { k.keyCode, k.flags | LALT_HELD })
#define RALT(k)   ((Key) { k.keyCode, k.flags | RALT_HELD })
#define LSHIFT(k) ((Key) { k.keyCode, k.flags | SHIFT_HELD })
#define LGUI(k)   ((Key) { k.keyCode, k.flags | GUI_HELD })

I wonder why of all four modifiers Ctrl, Alt, Shift and Gui, only Alt has two flags for separate left and right?

Relative to the other three modifiers, it is very common for the left and right alt keys to have different functions in an OS. In particular, with non-US keyboard layouts it’s very common for right alt to be AltGr, which causes other keys to produce accented characters (among other things).

Thanks for your reply. In XKB, in fact RAlt is the default third level modifier. But so is RCtrl the default fifth level modifier. Is there a way to specifically select this as available for RAlt?

Sorry; I don’t understand the question.

I mean, the availability of the RALT separate flag allows me to tell Kaleidoscope (by mapping a key to RALT(Key_X)) to imitate a RAlt + X keystroke which my OS can interpret as the third shift level on the key X, but similarly how to imitate a RCtrl + X keystroke which my OS can interpret to request the fifth shift level?

The best way to do that is probably with the Kaleidoscope-Macros plugin.

1 Like

As @merlin said, macros are your best bet here. The reason we don’t have an RCTL(x) macro is because we ran out of bits.

1 Like

It’s perhaps worth noting that it’s possible to use the five modifier flag bits to get access to all eight modifier keycodes. QMK does this, in fact, by using four of the bits for control, shift, alt, and gui, and the fifth bit to indicate which side (right or left) modifiers are used. This gives access to all the right-side modifiers as well as the left-side ones, but it’s not possible to combine left-side modifiers with right-side ones.

It’s not clear to me which way is better – the trade-offs don’t seem to be huge either way.

1 Like