keyboard/qmk/keyboards/dz60/keymaps/_bonfire/not-in-use/super-alt-tab.c

37 lines
1.1 KiB
C

/**
* Cool Function where a single key does ALT+TAB
* From: https://beta.docs.qmk.fm/features/feature_macros#super-alt-tab
*/
bool is_alt_tab_active = false; // ADD this near the begining of keymap.c
uint16_t alt_tab_timer = 0; // we will be using them soon.
enum custom_keycodes { // Make sure have the awesome keycode ready
ALT_TAB = SAFE_RANGE,
};
// key processing
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) { // This will do most of the grunt work with the keycodes.
case ALT_TAB:
if (record->event.pressed) {
if (!is_alt_tab_active) {
is_alt_tab_active = true;
register_code(KC_LALT);
}
alt_tab_timer = timer_read();
register_code(KC_TAB);
} else {
unregister_code(KC_TAB);
}
break;
}
return true;
}
// The very important timer.
void matrix_scan_user(void) {
if (is_alt_tab_active && timer_elapsed(alt_tab_timer) > 1000) {
unregister_code(KC_LALT);
is_alt_tab_active = false;
}
}