Advertisement
hakbraley

QMK Double Space Mode

Aug 30th, 2022
1,093
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.46 KB | None | 0 0
  1. /*  https://www.reddit.com/r/olkb/comments/x1ju6n/help_for_a_double_space_macro_on_qmk/
  2.  *  Code to create a toggleable mode where pressing space sends two spaces instead.
  3.  *  It also sets the color of the space bar to blue when this mode is active.
  4.  *  This can go into keymap.c
  5.  */
  6.  
  7. bool double_space_mode = false;  // variable to track status of double space mode
  8.  
  9. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  10.     switch(keycode) {
  11.         case TOG_2SPC:
  12.             if (record->event.pressed)   // when TOG_2SPC is pressed
  13.                 double_space_mode ^= 1;  // toggle double_space_mode
  14.             return false;
  15.  
  16.         case KC_SPACE:
  17.             if (record->event.pressed && double_space_mode) {  // if double space mode is active
  18.                 SEND_STRING("  ");  // send two spaces
  19.                 return false;       // do nothing else
  20.             }
  21.             return true;                                       // otherwise, act as a normal space key
  22.     }
  23.  
  24.     return true;
  25. }
  26.  
  27.  
  28. // LED Index for SPACE key.  Look in the rev_010x.c file for your keyboard version to find this
  29. // https://github.com/qmk/qmk_firmware/blob/master/keyboards/keychron/q1/rev_0100/rev_0100.c#L124
  30. #define SPACE_LED_IDX 75
  31.  
  32. void rgb_matrix_indicators_user(void) {
  33.   if (double_space_mode)                            // if double space mode is active
  34.     rgb_matrix_set_color(SPACE_LED_IDX, RGB_BLUE);  // set color of SPACE key's LED to blue
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement