# Using the butterfly key as a modifier

**URL:** <https://community.keyboard.io/t/using-the-butterfly-key-as-a-modifier/2174>\
**Category:** Programming\
**Created:** [November 7, 2018, 4:53pm UTC](https://community.keyboard.io/t/using-the-butterfly-key-as-a-modifier/2174 "2018-11-07T16:53:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeterM](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@PeterM](https://community.keyboard.io/u/PeterM)\
**Post date:** [November 7, 2018, 4:53pm UTC](https://community.keyboard.io/t/using-the-butterfly-key-as-a-modifier/2174/1 "2018-11-07T16:53:51Z")

</div>

For the purposes of typing Welsh, I would like to use the butterfly key to generate vowels with diacritics so that (Butterfly + a) generates the character â etc. I have successfully made some very basic changes to key mapping but this has defeated me so far. Any pointers would be gratefully received.

---

<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:** [November 7, 2018, 5:33pm UTC](https://community.keyboard.io/t/using-the-butterfly-key-as-a-modifier/2174/2 "2018-11-07T17:33:54Z")

</div>

The hard part about this is the `â` generation. There are two major ways this is usually accomplished:

- You can use a language-specific layout on the OS side, in which case certain symbols turn into others. For example, in HU-QWERTZ, `;` becomes `é`, and to input `;`, one must use `AltGr + ,`. A variant of this is where symbols stay US-QWERTY, but you use `AltGr` to access language-specific ones.

- Another way is to use a compose key, which makes it possible to input `â` by pressing the `AltGr ^ a` sequence.

To accomplish what you want, you will first need to decide how to input the symbols you need, create a set of Macros, and then you can turn the butterfly key into a `ShiftToLayer(WELSH)` key, where you map the `a` key to a macro that inputs `â`. The macros are sadly non-trivial, because they need to pay attention to `shift` too.

We started developing plugins that make these things easier, but they’re not all that usable yet. I’m happy to help you create a sketch that allows you to input Welsh, I’ll even write the macros (or plugin, whichever turns out to be easier) for you. I do need to know how you input Welsh symbols on a traditional keyboard, that should be enough to get me started. 🙂

---

<div class="post-metadata">

**Author:** ![PeterM](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@PeterM](https://community.keyboard.io/u/PeterM)\
**Post date:** [November 8, 2018, 6:00pm UTC](https://community.keyboard.io/t/using-the-butterfly-key-as-a-modifier/2174/3 "2018-11-08T18:00:28Z")

</div>

Thanks for the reply, Gergely. 🙂

I usually use an android device for my Welsh lessons where you can hold on a key in the Google keyboard and select an accented character from a popup. On a traditional keyboard I use Alt + numeric pad to enter accented characters so I know the ANSI codes, What I am getting stuck over is how to represent these in the code.

---

<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:** [November 13, 2018, 11:12pm UTC](https://community.keyboard.io/t/using-the-butterfly-key-as-a-modifier/2174/4 "2018-11-13T23:12:46Z")

</div>

> [@PeterM](#):
>
> What I am getting stuck over is how to represent these in the code.

With a macro, that does the `Alt+Numpad` magic under the hood. Something along these lines:

```c++
enum {
 MACRO_ACARET,
 MACRO_SOMETHINGELSE
};

const macro_t *macroAction(uint8_t macro_index, uint8_t key_state) {
  switch(macro_index) {
  case MACRO_ACARET:
    return MACRO(D(RightAlt), T(Keypad_0), ..., U(RightAlt));
  }
  return MACRO_NONE;
}

```

Repeat for every symbol you wish to enter, and done. Pretty much.

---

<div class="post-metadata">

**Author:** ![PeterM](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@PeterM](https://community.keyboard.io/u/PeterM)\
**Post date:** [November 13, 2018, 11:31pm UTC](https://community.keyboard.io/t/using-the-butterfly-key-as-a-modifier/2174/5 "2018-11-13T23:31:50Z")

</div>

Perfect! Exactly what I needed. Many thanks 🙂
