Advertisement
hakbraley

QMK Shift swap

Aug 25th, 2021
755
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  2.     switch(keycode) {
  3.         case KC_LBRC:  //if keycode is [
  4.         case KC_RBRC:  //or keycode is ]
  5.             if (record->event.pressed) {  //if this is a keydown event
  6.                 if (get_mods() & MOD_MASK_SHIFT) {   //if a shift key is held
  7.                     uint8_t temp_mods = get_mods();  //store the current mods that are held
  8.                     del_mods(MOD_MASK_SHIFT);        //ignore both shift keys
  9.                     tap_code(keycode);               //tap the key without shift, types a  [  or  ]
  10.                     set_mods(temp_mods);             //add back shift key(s)
  11.                 } else {                        //if shift is not held
  12.                     tap_code16(LSFT(keycode));  //tap the key with shift, types a  {  or  }
  13.                 }
  14.             }
  15.             return false;  //do not process the key as normal
  16.        
  17.         case MACRO1:  //other macro code
  18.             //...
  19.             break;
  20.     }
  21.     return true;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement