qmkqmk-firmware

KC_TAB release is not registered in macro


I try to overwrite the behavior of the Tab key, if Left Alt is hold down. In that case, I want it to act like a Shift key:

    switch (keycode) {
    case KC_TAB:
        // If left alt is pressed, treat tab as left shift
        if (get_mods() == MOD_BIT(KC_LALT)) {
            if (record->event.pressed) {
                register_code(KC_LSFT);
            } else {
                unregister_code(KC_LSFT);
            }
            return false;
        }
        return true;
    }

This works when I press Tab, it is registered as Left Shift, but when I release the Tab key again, it still shows Left Shift as pressed. What am I missing here?


Solution

  • I figured it out fortunately. The issue was the check if Left Alt was pressed. I replaced get_mods() == MOD_BIT(KC_LALT) with get_mods() & MOD_BIT(KC_LALT) as the first comparison would return false if Alt and Shift were pressed, which was the case when I was releasing the Tab key again.