From 83a00379718168dc139e504d3a59a9691963b688 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Mon, 9 Nov 2020 20:04:35 -0600 Subject: [PATCH] Use Qukeys min prior interval only after printable characters Some users have pointed out that certain keys (in particular, `space` & `backspace`) are inconvenient to require the minimum prior interval to make a qukey resolve to a modifier (especially `shift`). We could blacklist those keys, but it's hard to predict what they all might be. The problem is mainly one for very fast typists, and therefore I expect it to show up when following the "normal" printable keys, not often other keys. This could also be made into a configurable list, but I'd prefer not to do so unless there's serious demand for it, as Qukeys already has too many settings. Signed-off-by: Michael Richters --- docs/NEWS.md | 5 +++-- src/kaleidoscope/plugin/Qukeys.cpp | 11 ++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/NEWS.md b/docs/NEWS.md index 3326b470..d6c7bdef 100644 --- a/docs/NEWS.md +++ b/docs/NEWS.md @@ -20,8 +20,9 @@ the output, particularly when typing fast: - `Qukeys.setMinimumHoldTime(ms)` sets the minimum duration of a qukey press required for it to be eligible to take on its alternate (modifier) value. - `Qukeys.setMinimumPriorInterval(ms)` sets the minimum interval between the - previous non-modifier key press and the press of the qukey required to make - the qukey eligible to take on its alternate (modifier) value. + previous printable (letters, numbers, and punctuation) key press and the press + of the qukey required to make the qukey eligible to take on its alternate + (modifier) value. ### KALEIDOSCOPE_API_VERSION bump diff --git a/src/kaleidoscope/plugin/Qukeys.cpp b/src/kaleidoscope/plugin/Qukeys.cpp index f6ec29af..b5da1cab 100644 --- a/src/kaleidoscope/plugin/Qukeys.cpp +++ b/src/kaleidoscope/plugin/Qukeys.cpp @@ -185,7 +185,7 @@ bool Qukeys::processQueue() { // key, so we don't need to do it repeatedly later. bool qukey_is_spacecadet = isModifierKey(queue_head_.primary_key); - // If the qukey press followed a non-modifier key too closely, it's not + // If the qukey press is followed a printable key too closely, it's not // eligible to take on its alternate value unless it's a SpaceCadet-type key. if (!Runtime.hasTimeExpired(prior_keypress_timestamp_, minimum_prior_interval_) && @@ -291,8 +291,13 @@ void Qukeys::flushEvent(Key event_key) { KeyAddr queue_head_addr = event_queue_.addr(0); uint8_t keyswitch_state = event_queue_.isRelease(0) ? WAS_PRESSED : IS_PRESSED; - // If the flushed event is a keypress of a non-modifier, record its timestamp: - if (!event_queue_.isRelease(0) && !isModifierKey(event_key)) { + // If the flushed event is a keypress of a printable symbol, record its + // timestamp. This lets us suppress some unintended alternate values seen by + // fast typists by requiring a minimum interval between this keypress and the + // next qukey press in order for that qukey to become alternate-eligible. + if (!event_queue_.isRelease(0) && + ((event_key >= Key_A && event_key <= Key_0) || + (event_key >= Key_Minus && event_key <= Key_Slash))) { prior_keypress_timestamp_ = event_queue_.timestamp(0); }