/* * [name] * Toggle * * [description] * Toggle the key pressed or unpressed */ void kbfun_toggle(void) { uint8_t keycode = kb_layout_get(LAYER, ROW, COL); if (_kbfun_is_pressed(keycode)) _kbfun_press_release(false, keycode); else _kbfun_press_release(true, keycode); }
void kbfun_shift_press_release(void) { if (IS_PRESSED) { sh_key_count += 1; } else { sh_key_count -= 1; } if (sh_key_count > 0) { _kbfun_press_release(1, KEY_LeftShift); } else { _kbfun_press_release(0, KEY_LeftShift); } kbfun_press_release_no_check_sh(); }
/* * [name] * Two keys => capslock * * [description] * When assigned to two keys (e.g. the physical left and right shift keys) * (in both the press and release matrices), pressing and holding down one of * the keys will make the second key toggle capslock * * [note] * If either of the shifts are pressed when the second key is pressed, they * wil be released so that capslock will register properly when pressed. * Capslock will then be pressed and released, and the original state of the * shifts will be restored */ void kbfun_2_keys_capslock_press_release(void) { static uint8_t keys_pressed; static bool lshift_pressed; static bool rshift_pressed; uint8_t keycode = kb_layout_get(LAYER, ROW, COL); if (!IS_PRESSED) keys_pressed--; // take care of the key that was actually pressed _kbfun_press_release(IS_PRESSED, keycode); // take care of capslock (only on the press of the 2nd key) if (keys_pressed == 1 && IS_PRESSED) { // save the state of left and right shift lshift_pressed = _kbfun_is_pressed(KEY_LeftShift); rshift_pressed = _kbfun_is_pressed(KEY_RightShift); // disable both _kbfun_press_release(false, KEY_LeftShift); _kbfun_press_release(false, KEY_RightShift); // press capslock, then release it _kbfun_press_release(true, KEY_CapsLock); usb_keyboard_send(); _kbfun_press_release(false, KEY_CapsLock); usb_keyboard_send(); // restore the state of left and right shift if (lshift_pressed) _kbfun_press_release(true, KEY_LeftShift); if (rshift_pressed) _kbfun_press_release(true, KEY_RightShift); } if (IS_PRESSED) keys_pressed++; }
/* * Toggle the key pressed or unpressed */ void kbfun_toggle(void) { uint8_t keycode = _kbfun_get_keycode(); bool is_pressed = _kbfun_is_pressed(keycode); _kbfun_press_release(!is_pressed, keycode); }
/* * Generate a normal keypress or keyrelease * While basing the sticky key state transition on whether * kbfun_press_release() was called after kbfun_transparent() generally * works in practice, it is not always the desired behavior. One of the * benefits of sticky keys is avoiding key chording, so we want to make sure * that standard modifiers do not interrupt the sticky key cycle. Use * kbfun_press_release_preserve_sticky() if you want to define a standard * modifier key (shift, control, alt, gui) on the sticky layer instead of * defining the key to be transparent for the layer. */ void kbfun_press_release_preserve_sticky() { uint8_t keycode = _kbfun_get_keycode(); _kbfun_press_release(main_arg_is_pressed, keycode); }
/* * [name] * Press|Release and preserve top layer sticky key state * * [description] * Generate a normal keypress or keyrelease * While basing the sticky key state transition on whether * kbfun_press_release() was called after kbfun_transparent() generally * works in practice, it is not always the desired behavior. One of the * benefits of sticky keys is avoiding key chording, so we want to make sure * that standard modifiers do not interrupt the sticky key cycle. Use * kbfun_press_release_preserve_sticky() if you want to define a standard * modifier key (shift, control, alt, gui) on the sticky layer instead of * defining the key to be transparent for the layer. */ void kbfun_press_release_preserve_sticky(void) { uint8_t keycode = kb_layout_get(LAYER, ROW, COL); _kbfun_press_release(IS_PRESSED, keycode); }
/* * [name] * Control + press|release * * [description] * Generate a 'control' press or release before the normal keypress or * keyrelease */ void kbfun_ctrl_press_release(void) { _kbfun_press_release(IS_PRESSED, KEY_LeftControl); kbfun_press_release(); }
/* * [name] * Shift + press|release * * [description] * Generate a 'shift' press or release before the normal keypress or * keyrelease */ void kbfun_shift_press_release(void) { _kbfun_press_release(IS_PRESSED, KEY_LeftShift); kbfun_press_release(); }
static inline void numpad_toggle_numlock(void) { _kbfun_press_release(true, KEY_LockingNumLock); usb_keyboard_send(); _kbfun_press_release(false, KEY_LockingNumLock); usb_keyboard_send(); }
void kbfun_control_alt_gui_press_release(void) { _kbfun_press_release(IS_PRESSED, KEY_LeftControl); _kbfun_press_release(IS_PRESSED, KEY_LeftAlt); _kbfun_press_release(IS_PRESSED, KEY_LeftGUI); kbfun_press_release(); }
void kbfun_alt_press_release(void) { _kbfun_press_release(IS_PRESSED, KEY_LeftAlt); kbfun_press_release(); }
void kbfun_gui_press_release(void) { _kbfun_press_release(IS_PRESSED, KEY_LeftGUI); kbfun_press_release(); }