# Double click for CapsLock?

**URL:** <https://community.keyboard.io/t/double-click-for-capslock/1555>\
**Category:** Help and Getting Started\
**Created:** [May 21, 2018, 12:03pm UTC](https://community.keyboard.io/t/double-click-for-capslock/1555 "2018-05-21T12:03:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ewosborne](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/ewosborne/32/1286_2.png) [@ewosborne](https://community.keyboard.io/u/ewosborne)\
**Post date:** [May 21, 2018, 12:03pm UTC](https://community.keyboard.io/t/double-click-for-capslock/1555/1 "2018-05-21T12:03:06Z")

</div>

I occasionally use caps lock, and so I thought it’d be nice to toggle it via OneShot. This works:

OSM(LeftShift)…OSM(RightShift)  
and I also use ActiveModColor along side it

but it’s not exactly what I want. If I double click on either shift it does the OneShot+mod color thing just fine, but it also ‘capitalizes’ non-alphabetic characters (, . / - and the numerics). Is there a way to set it up so that a double click of shift leaves me in caps lock just like in OneShot, but only for a-z?

---

<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:** [May 21, 2018, 12:17pm UTC](https://community.keyboard.io/t/double-click-for-capslock/1555/2 "2018-05-21T12:17:40Z")

</div>

> [@ewosborne](#):
>
> Is there a way to set it up so that a double click of shift leaves me in caps lock just like in OneShot, but only for a-z?

Do you want to use `Shift` in a one-shot mode? Or were you trying one-shot only for the dobule-tap locking behaviour?

If the latter, then TapDance can help, and I’ll happily provide an example. If the former… that’s a bit harder to accomplish, as there is no ready-made solution just yet (but I guess a combination of tap-dance and oneshot could work…)

---

<div class="post-metadata">

**Author:** ![ewosborne](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/ewosborne/32/1286_2.png) [@ewosborne](https://community.keyboard.io/u/ewosborne)\
**Post date:** [May 21, 2018, 12:33pm UTC](https://community.keyboard.io/t/double-click-for-capslock/1555/3 "2018-05-21T12:33:02Z")

</div>

I like OneShot for other things, but specific to caps lock I was only using shift+OneShot for double tap locking behavior, at least so far. If you can provide an example that’d be great. Thanks!

eric

---

<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:** [May 21, 2018, 12:46pm UTC](https://community.keyboard.io/t/double-click-for-capslock/1555/4 "2018-05-21T12:46:39Z")

</div>

```auto
void tapDanceAction(uint8_t tapDanceIndex, byte row, byte col, 
                    uint8_t tapCount, 
                    kaleidoscope::TapDance::ActionType tapDanceAction) {

  switch (tapDanceIndex) {
  case SHIFT_CAPS: 
    {
      static bool isCapsOn;

      if (tapDanceAction == kaleidoscope::TapDance::Release) {
        Macros.play(MACRO(T(CapsLock)));

        if (isCapsOn) {
          isCapsOn = false;
          return;
        }
        isCapsOn = true;
      }

      return tapDanceActionKeys(tapCount, tapDanceAction,
                                Key_LeftShift, Key_CapsLock);
    }
  }
}

```

When you press this once and hold it, it will act as a `LeftShift`. Tap it twice, and it will become `CapsLock`. To make it possible to turn `Caps Lock` off with a single tap, we remember if it turned on, and regardless of `tapCount`, turn it off if it was on.

Mind you, this is untested, you may have to adjust it a little.

---

<div class="post-metadata">

**Author:** ![fedward](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/fedward/32/955_2.png) [@fedward](https://community.keyboard.io/u/fedward)\
**Post date:** [May 22, 2018, 2:40pm UTC](https://community.keyboard.io/t/double-click-for-capslock/1555/5 "2018-05-22T14:40:28Z")

</div>

This is where I plug [my plugin](https://community.keyboard.io/t/kaleidoscope-capslock-turns-letter-keys-red-when-caps-lock-is-on/993?u=fedward), which does light up the keys, but which is triggered by a press of `Key_CapsLock` instead of a double tap of a shift key. It may or may not be close enough to the functionality you want. I’m not sure how it would behave if you used TapDance to send the `Key_CapsLock` event instead of binding it somewhere in your keymap, but if you try it and it works in combination with TapDance report back!

---

<div class="post-metadata">

**Author:** ![ewosborne](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/ewosborne/32/1286_2.png) [@ewosborne](https://community.keyboard.io/u/ewosborne)\
**Post date:** [May 25, 2018, 7:54pm UTC](https://community.keyboard.io/t/double-click-for-capslock/1555/6 "2018-05-25T19:54:41Z")

</div>

I’m finally getting around to trying this.

Newbie Arduino question: I’m on Windows, where do I put your code once I download it from Github? I see C:\Program Files (x86)\Arduino\examples\ but don’t see a keyboardio directory anywhere obvious. Do I put something in ‘additional board manager urls’?

eric

---

<div class="post-metadata">

**Author:** ![fedward](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/fedward/32/955_2.png) [@fedward](https://community.keyboard.io/u/fedward)\
**Post date:** [May 26, 2018, 7:01pm UTC](https://community.keyboard.io/t/double-click-for-capslock/1555/7 "2018-05-26T19:01:17Z")

</div>

It goes under `Arduino/keyboardio/hardware/avr/libraries`, which is a directory that will be created when you follow the [Kaleidoscope build instructions](https://github.com/keyboardio/Kaleidoscope). I’m also new at Arduino, so I don’t know how the “additional board manager urls” configuration would work.
