Skip to content

Instantly share code, notes, and snippets.

@YCF
Created March 29, 2018 13:00
Show Gist options
  • Save YCF/7981bfc284897bfcbf5d204b199188a9 to your computer and use it in GitHub Desktop.
Save YCF/7981bfc284897bfcbf5d204b199188a9 to your computer and use it in GitHub Desktop.
按下shift ,某一键变为其他键
//shift + enter = " 来自:https://github.com/qmk/qmk_firmware/blob/e899cb8940da04fa2610604f0aab417db7fac119/keyboards/mitosis/keymaps/datagrok/keymap.c
bool comm_shifted = false;
bool ques_shifted = false;
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
uint8_t shifted;
uint16_t s_keycode;
bool *k_shifted;
switch (keycode) {
//特殊 shift
case KC_ENT:
s_keycode = KC_QUOT;
k_shifted = &ques_shifted;
break;
case KC_BSPC:
s_keycode = KC_PIPE;
k_shifted = &ques_shifted;
break;
default:
return true;
}
shifted = get_mods() & (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT));
// Keydown. If shift is currently pressed, register its alternate keycode.
if (record->event.pressed && shifted) {
*k_shifted = true;
register_code(s_keycode);
return false;
// Keyup. If shift was pressed back when the key was pressed, unregister
// its alternate keycode.
} else if (!(record->event.pressed) && *k_shifted) {
*k_shifted = false;
unregister_code(s_keycode);
return false;
// Otherwise, behave as normal.
} else {
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment