# Help me set up layer switching how I want

**URL:** <https://community.keyboard.io/t/help-me-set-up-layer-switching-how-i-want/4214>\
**Category:** Uncategorized\
**Created:** [October 10, 2020, 1:57am UTC](https://community.keyboard.io/t/help-me-set-up-layer-switching-how-i-want/4214 "2020-10-10T01:57:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![fire](https://avatars.discourse-cdn.com/v4/letter/f/67e7ee/32.png) [@fire](https://community.keyboard.io/u/fire)\
**Post date:** [October 10, 2020, 1:57am UTC](https://community.keyboard.io/t/help-me-set-up-layer-switching-how-i-want/4214/1 "2020-10-10T01:57:06Z")

</div>

So I have “red” and “green” function keys.

Each other key has four characters associated with it: white, red, green, blue

This is the behavior I want:

If Red is pressed once, and no other function keys are pressed, next keypress is the red character, everything else is the white character.  
If Red is pressed twice, and no other function keys are pressed, everything after that is the red character. Then if the Red key is pressed again, everything else is the white character.

If Green is pressed once, and no other function keys are pressed, next keypress is the green character, everything else is the white character.  
If Green is pressed twice, and no other function keys are pressed, everything after that is the green character. Then if the Green key is pressed again, everything else is the white character.

If either function key is pressed once, and then the other is pressed once, and no other function keys are pressed, the next character is the blue one, and everything after that is the white character.

If a function key is pressed twice in a row, and then optionally some characters are typed, and then the other function key is pressed once, and no other function keys are pressed, all characters after that are the blue ones. Then if any function key is pressed, everything after that is the white character.

Is there a simple way of doing this or something like this? I keep getting in weird states where neither function key works.

---

<div class="post-metadata">

**Author:** ![fire](https://avatars.discourse-cdn.com/v4/letter/f/67e7ee/32.png) [@fire](https://community.keyboard.io/u/fire)\
**Post date:** [October 10, 2020, 2:14am UTC](https://community.keyboard.io/t/help-me-set-up-layer-switching-how-i-want/4214/2 "2020-10-10T02:14:28Z")

</div>

(It doesn’t have to be exactly this - I just need some easy way of getting in or out of the seven different states: normal, red lock, green lock, blue lock, red one-shot, green one-shot, blue one-shot)

---

<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:** [October 10, 2020, 2:14am UTC](https://community.keyboard.io/t/help-me-set-up-layer-switching-how-i-want/4214/3 "2020-10-10T02:14:58Z")

</div>

You should be able to get _most_ of what you want, but there’s a bug in the current version of OneShot that will get in the way. To get the last little bit, you’d need a custom plugin.

[Explanation coming shortly]

---

<div class="post-metadata">

**Author:** ![fire](https://avatars.discourse-cdn.com/v4/letter/f/67e7ee/32.png) [@fire](https://community.keyboard.io/u/fire)\
**Post date:** [October 10, 2020, 2:15am UTC](https://community.keyboard.io/t/help-me-set-up-layer-switching-how-i-want/4214/4 "2020-10-10T02:15:16Z")

</div>

Ok, how do I get most of it?

---

<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:** [October 10, 2020, 2:29am UTC](https://community.keyboard.io/t/help-me-set-up-layer-switching-how-i-want/4214/5 "2020-10-10T02:29:42Z")

</div>

So, I assume you’ve already discovered OneShot layers, which are supposed to do what you want (except the last little bit, which probably isn’t worth it). I’ll assume the layers are as follows, from bottom to top:

- `0`: `WHITE`
- `1`: `RED`
- `2`: `GREEN`
- `3`: `BLUE`

I’ll call the two “function” keys red and green.

Mapping for red on each layer:

- `WHITE` =\> `OSL(RED)`
- `RED` =\> `Key_Transparent`
- `GREEN` =\> `OSL(BLUE)`
- `BLUE` =\> `Key_Transparent`

Mapping for green on each layer:

- `WHITE` =\> `OSL(GREEN)`
- `RED` =\> `OSL(BLUE)`
- `GREEN` =\> `Key_Transparent`
- `BLUE` =\> `Key_Transparent`

This should work (except that you would always need to double-tap the second “function” key to lock the `BLUE` layer active), but it won’t, because of the aforementioned bug.

The problem is that, with the current version of OneShot, double-tapping green won’t lock the `GREEN` layer, because as soon as you release the key, it will be mapped to `OSL(BLUE)` instead of staying as `OSL(GREEN)`. The good news is that there is a PR open against Kaleidoscope right now that would fix this (#905). If you’re comfortable with checking out a git branch and building your own firmware, you can try it out, and get the vast majority of what you want.

---

<div class="post-metadata">

**Author:** ![fire](https://avatars.discourse-cdn.com/v4/letter/f/67e7ee/32.png) [@fire](https://community.keyboard.io/u/fire)\
**Post date:** [October 10, 2020, 2:42am UTC](https://community.keyboard.io/t/help-me-set-up-layer-switching-how-i-want/4214/6 "2020-10-10T02:42:50Z")

</div>

I tried something like that and ended up stuck locked on the Blue layer. How does getting out of the Blue layer work with that?

---

<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:** [October 10, 2020, 5:35am UTC](https://community.keyboard.io/t/help-me-set-up-layer-switching-how-i-want/4214/7 "2020-10-10T05:35:34Z")

</div>

Oh, right. That’s also a problem with the current version of OneShot, but will work the way you want if [#905](https://github.com/keyboardio/Kaleidoscope/pull/905) gets merged.

---

<div class="post-metadata">

**Author:** ![fire](https://avatars.discourse-cdn.com/v4/letter/f/67e7ee/32.png) [@fire](https://community.keyboard.io/u/fire)\
**Post date:** [October 10, 2020, 5:56pm UTC](https://community.keyboard.io/t/help-me-set-up-layer-switching-how-i-want/4214/8 "2020-10-10T17:56:50Z")

</div>

Thanks for all your help here (and I’m [famous](https://github.com/keyboardio/Kaleidoscope/pull/905#issuecomment-706492223) now!)

Can you elaborate on the other problem with the current OneShot and the changed behavior in #905?

---

<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:** [October 10, 2020, 11:08pm UTC](https://community.keyboard.io/t/help-me-set-up-layer-switching-how-i-want/4214/9 "2020-10-10T23:08:38Z")

</div>

> [@fire](#):
>
> Can you elaborate on the other problem with the current OneShot and the changed behavior in #905?

OneShot is, in essence, emulating the user holding down a key after the key is released. Unfortunately, the current version of OneShot does this by emulating the key _value_ being active, not the key _position_. This means that if you hold one of your `red` or `green` OSL keys, then the other one, then let go of the first one, you won’t have any keys that map to `OSL(BLUE)`, which is what you need to press to cancel the “sticky” blue layer.

With PR #905, OneShot will emulate the key at a certain position being held, and therefore its value will remain active as a OneShot layer that, when tapped again, will deactivate the target layer, preventing that layer getting “stuck”.
