Last active
September 15, 2024 18:47
-
-
Save xdlg/1c4978f87f9db6f11fe48fc2ba728b68 to your computer and use it in GitHub Desktop.
Better Super Alt+Tab for QMK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adds the ALT_TAB keycode to a QMK keymap. | |
// Based on https://www.reddit.com/r/MechanicalKeyboards/comments/mrnxrj/better_super_alttab/ | |
// Functionality is the following (basically the same thing as a normal Alt + Tab but without having | |
// to leave Alt pressed): | |
// - On pressing ALT_TAB, the window switch menu pops up. | |
// - While the menu is visible, it's possible to cycle through the selection by pressing ALT_TAB | |
// again, or Shift + ALT_TAB, or the arrow keys. | |
// - The selected window can be brought up by pressing Enter, which also closes the menu. | |
// Alternatively, pressing Escape closes the menu without selecting anything. | |
enum custom_keycodes { | |
ALT_TAB = SAFE_RANGE, | |
}; | |
bool is_alt_tab_active = false; | |
bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |
switch (keycode) { | |
case ALT_TAB: | |
if (record->event.pressed) { | |
if (!is_alt_tab_active) { | |
is_alt_tab_active = true; | |
register_code(KC_LALT); | |
} | |
register_code(KC_TAB); | |
} else { | |
unregister_code(KC_TAB); | |
} | |
return false; | |
case KC_ENTER: | |
if (record->event.pressed) { | |
if (is_alt_tab_active) { | |
unregister_code(KC_LALT); | |
is_alt_tab_active = false; | |
return false; | |
} | |
} | |
return true; | |
case KC_ESCAPE: | |
if (record->event.pressed) { | |
if (is_alt_tab_active) { | |
register_code(KC_ESCAPE); | |
unregister_code(KC_LALT); | |
unregister_code(KC_ESCAPE); | |
is_alt_tab_active = false; | |
return false; | |
} | |
} | |
return true; | |
default: | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment