diff --git a/src/key_events.cpp b/src/key_events.cpp index ff071c66..e2692f3d 100644 --- a/src/key_events.cpp +++ b/src/key_events.cpp @@ -52,6 +52,8 @@ bool handle_key_event_default(Key mappedKey, byte row, byte col, uint8_t keyStat handle_synthetic_key_event( mappedKey, keyState); } else if (key_is_pressed(keyState)) { press_key(mappedKey); + } else if (key_toggled_off(keyState) && (keyState & INJECTED)) { + release_key(mappedKey); } return true; } @@ -76,6 +78,26 @@ void press_key(Key mappedKey) { } +void release_key(Key mappedKey) { + if (mappedKey.flags & SHIFT_HELD) { + Keyboard.release(Key_LShift.rawKey); + } + if (mappedKey.flags & CTRL_HELD) { + Keyboard.release(Key_LCtrl.rawKey); + } + if (mappedKey.flags & LALT_HELD) { + Keyboard.release(Key_LAlt.rawKey); + } + if (mappedKey.flags & RALT_HELD) { + Keyboard.release(Key_RAlt.rawKey); + } + if (mappedKey.flags & GUI_HELD) { + Keyboard.release(Key_LGUI.rawKey); + } + Keyboard.release(mappedKey.rawKey); +} + + void handle_keymap_key_event(Key keymapEntry, uint8_t keyState) { if (keymapEntry.flags & SWITCH_TO_KEYMAP_MOMENTARY ) { if (key_toggled_on(keyState)) { diff --git a/src/key_events.h b/src/key_events.h index d7128a1b..2bc6d799 100644 --- a/src/key_events.h +++ b/src/key_events.h @@ -48,6 +48,7 @@ void handle_key_event(Key mappedKey, byte row, byte col, uint8_t keyState); // Internal use void handle_synthetic_key_event( Key mappedKey, uint8_t keyState); void press_key(Key mappedKey); +void release_key(Key mappedKey); void handle_keymap_key_event(Key keymapEntry, uint8_t keyState); bool handle_key_event_default(Key mappedKey, byte row, byte col, uint8_t keyState);