Skip to content

Commit 41cb026

Browse files
wheredoesyourmindgoTimost
authored andcommitted
Added cancel_key_lock function (qmk#15321)
1 parent 06dfb40 commit 41cb026

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

docs/feature_key_lock.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ First, enable Key Lock by setting `KEY_LOCK_ENABLE = yes` in your `rules.mk`. Th
1919
Key Lock is only able to hold standard action keys and [One Shot modifier](one_shot_keys.md) keys (for example, if you have your Shift defined as `OSM(KC_LSFT)`).
2020
This does not include any of the QMK special functions (except One Shot modifiers), or shifted versions of keys such as `KC_LPRN`. If it's in the [Basic Keycodes](keycodes_basic.md) list, it can be held.
2121

22-
Switching layers will not cancel the Key Lock.
22+
Switching layers will not cancel the Key Lock. The Key Lock can be cancelled by calling the `cancel_key_lock()` function.
23+

quantum/process_keycode/process_key_lock.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ static inline uint16_t translate_keycode(uint16_t keycode) {
5656
}
5757
}
5858

59+
void cancel_key_lock(void) {
60+
watching = false;
61+
UNSET_KEY_STATE(0x0);
62+
}
63+
5964
bool process_key_lock(uint16_t *keycode, keyrecord_t *record) {
6065
// We start by categorizing the keypress event. In the event of a down
6166
// event, there are several possibilities:

quantum/process_keycode/process_key_lock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818

1919
#include "quantum.h"
2020

21+
void cancel_key_lock(void);
2122
bool process_key_lock(uint16_t *keycode, keyrecord_t *record);

0 commit comments

Comments
 (0)