EscapeOneShot: Always treat `Key_OneShotCancel` as cancel key

To make it easier to use a dedicated cancel key, always treat it as a cancel key
if seen, without having to set it via `setCancelKey()` on top. The key has no
use apart from this one task, lets make it easier to use.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/1089/head
Gergely Nagy 3 years ago
parent f3604d3317
commit ddad1305e2
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -5,6 +5,9 @@ effect - or act as the normal `Esc` key if none are active, or if any of them
are still held. For those times when one accidentally presses a one-shot key, or
change their minds.
Additionally, the special `Key_OneShotCancel` key will also count as a oneshot
cancel key, would one want a dedicated key for the purpose.
## Using the plugin
To use the plugin, one needs to include the header, and activate it. No further
@ -59,7 +62,7 @@ configuration methods:
> (including sticky) keys. The default is to use `Key_Escape` (the
> normal `Esc` key), but if you would rather have a dedicated key (so
> that you can use `Key_Escape` in combination with one-shot
> modifiers), there is the special `OneShotCancelKey`, which will not
> modifiers), there is the special `Key_OneShotCancel`, which will not
> have any side effects.
### `.getCancelKey(key)`

@ -38,7 +38,11 @@ EventHandlerResult EscapeOneShot::onKeyEvent(KeyEvent &event) {
// set) that has just been pressed, and not generated by some other
// plugin. Also, only if at least one OneShot key is active and/or
// sticky. Last, only if there are no OneShot keys currently being held.
if (event.key == settings_.cancel_oneshot_key &&
//
// `Key_OneShotCancel` will always count as an escape key, even if not
// explicitly set so.
if ((event.key == settings_.cancel_oneshot_key ||
event.key == Key_OneShotCancel) &&
keyToggledOn(event.state) &&
!keyIsInjected(event.state) &&
::OneShot.isActive()) {

@ -20,7 +20,10 @@
#include "kaleidoscope/Runtime.h"
#include <Kaleidoscope-Ranges.h>
// DEPRECATED: `OneShotCancelKey` doesn't match our normal naming, and should
// eventually be removed.
constexpr Key OneShotCancelKey {kaleidoscope::ranges::OS_CANCEL};
constexpr Key Key_OneShotCancel {kaleidoscope::ranges::OS_CANCEL};
namespace kaleidoscope {
namespace plugin {

Loading…
Cancel
Save