From c791e8163c7083e7c4cc99f47955097ef55fb573 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 31 May 2018 10:21:43 +0200 Subject: [PATCH] Implement OneShot.isPressed() Signed-off-by: Gergely Nagy --- README.md | 4 ++++ src/Kaleidoscope/OneShot.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 830bf079..df9eb36d 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,10 @@ modifiers and one-shot layer keys. It has the following methods: > useful for macros that need to fiddle with either modifier or layer state: if > one-shots are not active, they need not restore the original state. +### `.isPressed()` + +> Returns true if any one-shot key is still held. + ### `.isSticky(key)` > Returns if the key is currently sticky. diff --git a/src/Kaleidoscope/OneShot.h b/src/Kaleidoscope/OneShot.h index 0abfdd55..32751593 100644 --- a/src/Kaleidoscope/OneShot.h +++ b/src/Kaleidoscope/OneShot.h @@ -34,6 +34,9 @@ class OneShot : public kaleidoscope::Plugin { return (key.raw >= kaleidoscope::ranges::OS_FIRST && key.raw <= kaleidoscope::ranges::OS_LAST); } static bool isActive(void); + static bool isPressed() { + return !!pressed_state_.all; + } static bool isActive(Key key); static bool isSticky(Key key); static void cancel(bool with_stickies);