qmk / qmk_firmware

Open-source keyboard firmware for Atmel AVR and Arm USB families
https://qmk.fm
GNU General Public License v2.0
17.81k stars 38.17k forks source link

Impossible to create custom keys with standar repetition behavior #10224

Closed Zeioth closed 3 years ago

Zeioth commented 3 years ago

The next macro creates a custom key, that prints KC_QUOT, and KC_LBRC while shift is pressed. Both keys support standar key repetition while keys are holded.

    case CKC_ACCENT: // ´ and `
      if (record->event.pressed) {
        if (!(get_mods() & MOD_BIT(KC_LSHIFT) || get_mods() & MOD_BIT(KC_RSHIFT))){
          register_code(KC_QUOT); // If shift is not pressed, print this.
        } else{
          clear_mods(); // We clear shift here so we can indicate exactly the keycode we want it to print.
          register_code(KC_LBRC); // While shift is pressed, print this
        }
      }else {
        clear_keyboard();
      }
      return false;

The problem is, if you press SHIFT+KC_QUOT, release KC_QUOT and then press it again without releasing SHIFT, it will print KC_QUOT instead of KC_LBRC. This happens because in order to print a non standar value when shift is pressed, you must call clear_mods().

In resume: Please, could you provide an example of a custom key than behaves like an standar key on keyholding? Or is this a bug? Thank you.

Zeioth commented 3 years ago

More info available on reddit