From c6bb3f3ea3a7e7caacc8c250090152fd429d7da0 Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 6 May 2024 18:48:29 -0500 Subject: [PATCH] Copying and modifying the Shift Backspace example - https://docs.qmk.fm/#/feature_advanced_keycodes --- users/t4corun/t4corun.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/users/t4corun/t4corun.c b/users/t4corun/t4corun.c index 3471fdd9..68ed0572 100644 --- a/users/t4corun/t4corun.c +++ b/users/t4corun/t4corun.c @@ -42,16 +42,32 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return false; case KC_BSPC: { - - bool isShift = ( (get_mods() & MOD_BIT(KC_LSFT)) || (get_oneshot_mods() & MOD_BIT(KC_LSFT)) ); - + static bool delkey_registered = false; if (record->event.pressed) { - isShift ? register_code(KC_DEL) : register_code(KC_BSPC); - } else { - isShift ? unregister_code(KC_DEL) : unregister_code(KC_BSPC); - } + // Detect the activation of either shift keys + uint8_t current_mod = get_mods(); + uint8_t current_osm = get_oneshot_mods(); - return false; + if ((current_mod | current_osm) & MOD_MASK_SHIFT ) { + del_mods(MOD_MASK_SHIFT); + register_code(KC_DEL); + delkey_registered = true; + set_mods((current_mod | current_osm)); + return false; + } + + } else { + + if(delkey_registered) { + unregister_code(KC_DEL); + delkey_registered = false; + return false; + } + + } + + // QMK will process Backspace instead + return true; } //https://docs.qmk.fm/#/mod_tap?id=changing-both-tasp-and-hold