getreuer / qmk-keymap

My keymap & reusable QMK gems
Apache License 2.0
300 stars 45 forks source link

Caps word shifts `KC_MINS` on layer to `_` #12

Closed 0x64746b closed 2 years ago

0x64746b commented 2 years ago

Hi Pascal,

thanks for sharing your really nice QMK features! I just tried the caps word feature and stumbled upon KC_MINS (which lives on a layer in my keymap) being shifted to _. Is this the expected behavior? Am I holding it wrong? :)

Thanks again! D.

getreuer commented 2 years ago

Thanks for trying out Caps Word and the report! Yes, this behavior of shifting minus - to underscore _ is intended, since this is useful for all-caps identifiers in code, like typing "KC_" keycodes. But it is configurable if you don't prefer this. To continue Caps Word when KC_MINS is pressed, but without shifting it, add this to keymap.c:

bool caps_word_press_user(uint16_t keycode) {
  switch (keycode) {
    // Keycodes that continue Caps Word, with shift applied.
    case KC_A ... KC_Z:
      add_weak_mods(MOD_BIT(KC_LSFT));  // Apply shift to the next key.
      return true;

    // Keycodes that continue Caps Word, without shifting.
    case KC_1 ... KC_0:
    case KC_BSPC:
    case KC_DEL:
    case KC_UNDS:
    case KC_MINS:  // <--- Particularly, don't shift KC_MINS.
      return true;

    default:
      return false;  // Deactivate Caps Word.
  }
}

For documentation about this callback, see Configure which keys are “word breaking”.

0x64746b commented 2 years ago

D'oh, I saw both the documentation and that particular piece of code, but I somehow failed to parse the combined switch cases and the comments 🤦 Personally, I think I prefer to be able to still type all symbols while caps lock is on, but must admit that that might just be old thinking from when toggling caps lock was a nuisance and I tried to get away with typing operators between consecutive constants 😊 Thanks for the super quick reply!!

getreuer commented 2 years ago

Personally, I think I prefer to be able to still type all symbols while caps lock is on

I agree it's not a clear choice, especially between _ vs. - when writing code. I think _ and - are both so useful that I have dedicated two separate buttons for them on the base layer.

0x64746b commented 2 years ago

I think _ and - are both so useful that I have dedicated two separate buttons for them on the base layer.

Uuh, nice! I'm not brave enough for that ;) For all I have customised over the years (Colemak, column stagger, the custom symbols layers that come with 3x5 boards,...) I have a strange attachment to somewhat being able to occasionally switch to a notebook keyboard (which is a bit nonsensical - you won't catch me typing on qwerty, and even just sliding the numbers row down by one on my daily driver, even while preserving finger assignments, means lots of weird typos on a regular keyboard. Not to mention home row mods and thumb cluster). But what do you know 🤷‍♂️