diff --git a/README.md b/README.md index f70ed301..a4e0aa07 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,8 @@ still act as normal when held, that behaviour is not lost. Furthermore, if a one-shot key is tapped two times in quick succession, it becomes sticky, and remains active until disabled with a third tap. This can be useful when one needs to input a number of keys with the modifier or layer -active, and still does not wish to hold the key down. +active, and still does not wish to hold the key down. If this feature is +undesirable, unset the `OneShot.double_tap_sticky` property (see later). To make multi-modifier, or multi-layer shortcuts possible, one-shot keys remain active if another one-shot of the same type is tapped, so `Ctrl, Alt, b` becomes @@ -48,7 +49,7 @@ void setup() { ## Keymap markup -There are two macros the plugin provides: +There are two macros the plugin provides: ### `OSM(mod)` @@ -111,6 +112,15 @@ modifiers and one-shot layer keys. It has the following methods and properties: > > Defaults to 200. +### `.double_tap_sticky` + +> Set this boolean property to make the plugin treat a double-tap of a one-shot +> key as making it sticky until a third tap. Setting it to `false` disables this +> behaviour, in which case double-tapping a one-shot modifier will just restart +> the timer. +> +> Defaults to `true`. + ## Dependencies * [Kaleidoscope-Ranges](https://github.com/keyboardio/Kaleidoscope-Ranges) diff --git a/src/Kaleidoscope/OneShot.cpp b/src/Kaleidoscope/OneShot.cpp index 01ad5905..a648cbe0 100644 --- a/src/Kaleidoscope/OneShot.cpp +++ b/src/Kaleidoscope/OneShot.cpp @@ -25,6 +25,7 @@ namespace kaleidoscope { uint32_t OneShot::start_time_ = 0; uint16_t OneShot::time_out = 2500; uint16_t OneShot::hold_time_out = 250; +bool OneShot::double_tap_sticky = true; OneShot::state_t OneShot::state_; OneShot::state_t OneShot::sticky_state_; OneShot::state_t OneShot::pressed_state_; @@ -130,7 +131,7 @@ Key OneShot::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_st if (keyToggledOn(key_state)) { setPressed(idx); - if (isSameAsPrevious(mapped_key)) { + if (isSameAsPrevious(mapped_key) && double_tap_sticky) { setSticky(idx); saveAsPrevious(mapped_key); diff --git a/src/Kaleidoscope/OneShot.h b/src/Kaleidoscope/OneShot.h index c0c2aa07..93564860 100644 --- a/src/Kaleidoscope/OneShot.h +++ b/src/Kaleidoscope/OneShot.h @@ -39,6 +39,7 @@ class OneShot : public KaleidoscopePlugin { } static uint16_t time_out; static uint16_t hold_time_out; + static bool double_tap_sticky; static bool isModifierActive(Key key);