# Why does only ALT have separate LALT\_HELD and RALT\_HELD flags?

**URL:** <https://community.keyboard.io/t/why-does-only-alt-have-separate-lalt-held-and-ralt-held-flags/1627>\
**Category:** Programming\
**Created:** [June 13, 2018, 3:29pm UTC](https://community.keyboard.io/t/why-does-only-alt-have-separate-lalt-held-and-ralt-held-flags/1627 "2018-06-13T15:29:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamadagni](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/jamadagni/32/2030_2.png) [@jamadagni](https://community.keyboard.io/u/jamadagni)\
**Post date:** [June 13, 2018, 3:29pm UTC](https://community.keyboard.io/t/why-does-only-alt-have-separate-lalt-held-and-ralt-held-flags/1627/1 "2018-06-13T15:29:28Z")

</div>

See this section of `key_defs.h`:

```auto
#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?

---

<div class="post-metadata">

**Author:** ![merlin](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/merlin/32/3416_2.png) [@merlin](https://community.keyboard.io/u/merlin)\
**Post date:** [June 13, 2018, 3:39pm UTC](https://community.keyboard.io/t/why-does-only-alt-have-separate-lalt-held-and-ralt-held-flags/1627/2 "2018-06-13T15:39:09Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![jamadagni](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/jamadagni/32/2030_2.png) [@jamadagni](https://community.keyboard.io/u/jamadagni)\
**Post date:** [June 13, 2018, 3:43pm UTC](https://community.keyboard.io/t/why-does-only-alt-have-separate-lalt-held-and-ralt-held-flags/1627/3 "2018-06-13T15:43:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![merlin](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/merlin/32/3416_2.png) [@merlin](https://community.keyboard.io/u/merlin)\
**Post date:** [June 13, 2018, 3:45pm UTC](https://community.keyboard.io/t/why-does-only-alt-have-separate-lalt-held-and-ralt-held-flags/1627/4 "2018-06-13T15:45:00Z")

</div>

> [@jamadagni](#):
>
> Is there a way to specifically select this as available for RAlt?

Sorry; I don’t understand the question.

---

<div class="post-metadata">

**Author:** ![jamadagni](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/jamadagni/32/2030_2.png) [@jamadagni](https://community.keyboard.io/u/jamadagni)\
**Post date:** [June 13, 2018, 3:50pm UTC](https://community.keyboard.io/t/why-does-only-alt-have-separate-lalt-held-and-ralt-held-flags/1627/5 "2018-06-13T15:50:48Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![merlin](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/merlin/32/3416_2.png) [@merlin](https://community.keyboard.io/u/merlin)\
**Post date:** [June 13, 2018, 4:07pm UTC](https://community.keyboard.io/t/why-does-only-alt-have-separate-lalt-held-and-ralt-held-flags/1627/6 "2018-06-13T16:07:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![algernon](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/algernon/32/4404_2.png) [@algernon](https://community.keyboard.io/u/algernon)\
**Post date:** [June 13, 2018, 7:11pm UTC](https://community.keyboard.io/t/why-does-only-alt-have-separate-lalt-held-and-ralt-held-flags/1627/7 "2018-06-13T19:11:18Z")

</div>

> [@jamadagni](#):
>
> how to imitate a _RCtrl + X_ keystroke which my OS can interpret to request the fifth shift level?

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.

---

<div class="post-metadata">

**Author:** ![merlin](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/merlin/32/3416_2.png) [@merlin](https://community.keyboard.io/u/merlin)\
**Post date:** [June 14, 2018, 3:52am UTC](https://community.keyboard.io/t/why-does-only-alt-have-separate-lalt-held-and-ralt-held-flags/1627/8 "2018-06-14T03:52:31Z")

</div>

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.
