Leader key respecting the current state of shift

plugin

(michael) #1

I’m trying to reduce my german layout by turning the dedicated keys for ä, ö and ü into a “dead-key” for the diaeresis + the key for a, o and u.

The leader-plugin looked promising to fulfill that requirement. So I implemented the following:

static const kaleidoscope::Leader::dictionary_t leader_dictionary[] PROGMEM =
  LEADER_DICT(
    {LEADER_SEQ(LEAD(0), Key_A), leaderAE},
  );

static void leaderAE(uint8_t seq_index) {
  kaleidoscope::hid::pressKey(key);
  kaleidoscope::hid::sendKeyboardReport();
  kaleidoscope::hid::releaseKey(key);
}

I discovered two issues with this approach:

  1. I have to tap (press and release) the leader key before I start pressing the next key otherwise the next key seems to cancel the leader-key.
  2. My expectation was, that holding the shift-key while pressing the leader-sequence would result in a capital Ä. That is not the case. Instead my shift-key seems to get “locked” and I get allcaps till I press it again.

Is there a better approach? In order to be able to use my keyboardio on any (windows)-computer in germany one requirement is, that it should work with the default OS-keymap.

Any help will be greatly appreciated.


(Gergely Nagy) #2

Indeed, and this is by design. The Leader key is not a modifier, and doesn’t try to emulate one.

Part of this (shift getting locked) is a bug. Not working with shift is, again, by design - Leader does not support chording, only discrete keys. Making it support chording would be far too expensive as far as I can tell.

I’d suggest using a OneShot layer instead of a Leader key, that works fine with modifiers. On the oneshot layer, you can put either macros, or keys, wherever convenient.

I’m using this setup for Hungarian input, and it’s been a blast so far. (But then, I’m using OneShot for everything, which makes it a bit easier to get used to it.)


(michael) #3

Thank you @algernon. That is a perfect solution. I don’t know why I didn’t think of it in the first place.

Now I’m wondering if it is possible to put a OneShot layer onto the same key on the OneShot layer to simulate a kind of tap-dance behaviour where I can switch from é to è… Will try :slight_smile:

I’m still wondering about this. Because I would imagine tapping the leader-key and a sequence, which is in the dictionary, in quick succession so, that the first key of the sequence will end up pressed, before the leader key was released. To my understanding that is not possible at the moment.


(michael) #4

It is possible but it doesn’t work reliably. I manage to get stuck on my first diacritics layer when I try to do that. And I don’t always get to the second layer when I press the OSL-key twice while holding down shift. Maybe that has to do with my macros. I’m going to play around with it for a little while longer and am going to post an update if i figured what is going wrong.