• You are not logged in.
  • Index
  • General
  • Mapping one key to two modifiesr [xkb]

    Mapping one key to two modifiesr [xkb]

    • Started by stevep99
    • 7 Replies:
    • Reputation: 48
    • From: UK
    • Registered: 14-Apr-2014
    • Posts: 638

    Is it possible, in xkb, to define a key to act equivalently as though two other keys (modifiers) had been pressed.

    For example, let's say I have mappings for AltGr (3rd layer) and Extend (5th layer).  Can I define a single key that is equivalent to pressing AltGr and Extend, thus accessing the 7th layer via a single key?

    Using Colemak Mod-DH with some additional ergonomic keyboard mods.

    Offline
    • 0
    • Reputation: 48
    • From: UK
    • Registered: 14-Apr-2014
    • Posts: 638

    Hmm. Judging the title of this thread, I evidently still make occasional R/S errors! :/

    Last edited by stevep99 (25-Feb-2018 18:52:01)

    Using Colemak Mod-DH with some additional ergonomic keyboard mods.

    Offline
    • 0
    • Reputation: 87
    • From: Oslo, Norway
    • Registered: 13-Dec-2006
    • Posts: 4,472

    It should be possible, and I've been planning to do it for a while. I need a lvl7 modifier for my second Extend layer. But I haven't gotten around to it yet.

    Recall how I finally managed to remap Ctrl+Z and Shift+Ctrl+Z for Extend:

    Redirect(key=<AB01>,mods=Control,clearmods=LevelFive), Redirect(key=<AB01>,mods=Shift+Control,clearmods=LevelFive), // Ctrl+Z

    That was the craziest bit of XKB moddery I've performed so far, for sure! ^_^

    So I think this action should work:

    SetMods(mods=LevelThree+LevelFive)

    But I haven't tested it yet. Let me know if you find out something!

    Hmmm... check out symbols/level5("lock") and types/level5("EIGHT_LEVEL_LEVEL_FIVE_LOCK"). There it says that you need a "real" modifier key. So I guess we could do what they do, more or less, which is to cannibalize for instance the NumLock modifier. I'm really not familiar with the "types" definitions though. It may be that their need for the NumLock modifier was mostly driven by the desire to use its LED to show the lock state...?

    // This adds the definitions needed to create a level5-lock behaviour, using
    // the real modifier NumLock as a lock indicator.
    // See also: types/level5 : EIGHT_LEVEL_LEVEL_FIVE_LOCK
    // See also: compat/level5(level5_lock)
    partial modifier_keys
    xkb_symbols "lock" {
      key.type[Group1] = "ONE_LEVEL";
      include "level5(modifier_mapping)"
      replace key <HYPR> {
        vmods = NumLock,
        symbols[Group1] = [ NoSymbol ],
        actions[Group1] = [ SetMods(modifiers=NumLock) ]
      };
      modifier_map Mod2 { <HYPR> };
    };

    The level5 state is Mod3.

    Note in the above how they didn't map the <HYPR> key to a key symbol but directly to the SetMods() action. That's how I did my Extend mappings too.

    Maybe if I were more clever with my types definitions, I wouldn't have to add all those clearmods=LevelFive entries...

    Last edited by DreymaR (26-Feb-2018 17:42:53)

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 0
    • Reputation: 48
    • From: UK
    • Registered: 14-Apr-2014
    • Posts: 638

    Very nice! Yes, this seems to work:

        key <XXX> { symbols[Group1]=[ NoSymbol,NoSymbol,NoSymbol,NoSymbol],
                     actions[Group1]=[SetMods(mods=LevelThree+LevelFive),NoAction(),NoAction(),NoAction()]
                   };

    What I am interested in doing, is having all the mouse-function keys on this layer, and assign it to TAB.

    LeftAlt will continue to be my main Extend key.
    TAB will be my Extend+AltGr "mousing layer".

    The idea is for the keys in the mousing layer to be analogous to the main Extend layer. So, UNEI will move the mouse up/down/left/right just like the arrow keys. J and K will be mouse scroll (equivalent to page up/page down). Probably mouse buttons on the bottom row, H, comma, dot.

    Using Colemak Mod-DH with some additional ergonomic keyboard mods.

    Offline
    • 0
    • Reputation: 87
    • From: Oslo, Norway
    • Registered: 13-Dec-2006
    • Posts: 4,472

    The big question for me is: If I setmods differently for, say, the Caps key's first and third levels (AltGr+Caps), will the Caps key retain the set mods until released even if AltGr is released? Because that's my preferred way I think: AltGr+Caps selects Extend2, Caps alone holds it.

    Maybe all that majik with the "real mod" isn't necessary for us, or maybe we'll eventually discover that we've fubar'd something by our simple ways. Time will show.

    Mouse keys are a bit sucky. I think there are some accelerated and diagonal mouse keys that might help though. In XKB, it's simple to create your own using the action syntax in my extend file:

    MovePtr(x=+0,y=-8)

    Maybe a decent mouse layer with diagonals and a combo of big and small jumps could be nice?

    Instead of UNEI, I'd be tempted then to use E as mouse button 1 and H/,/. as the downward movements. Maybe M and O as middle/right button?

    Last edited by DreymaR (26-Feb-2018 19:30:35)

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 0
    • Reputation: 48
    • From: UK
    • Registered: 14-Apr-2014
    • Posts: 638

    Yeah, I saw your mouse movement command in the existing Extend layer, and since I tried this out yesterday, these have been working fine! You must have read my mind regarding diagonals, I have set those on LYM/.  I also set the Shifted versions to move the mouse double speed (-/+16), but that might not be necessary. To be honest, as you say, the mouse keys don't work *that* well, but still useful enough to have on what would otherwise be an unused layer.

    A similar thought occurred to me about whether mouse-down should be on comma, but I decided consistency with the arrow keys was more important. Also I like having the three buttons together, even though it might seem weird for them to be on the bottom row. The most common is left button anyway, and as we know, the H key (Qwerty M) is a very nice key.

    I haven't tried to configure the method of AltGr+Caps then release AltGr to select Extend2, but I remember trying something similar a while back to select the shifted AltGr layer, which seemed to work OK. But personally, I like the idea of having a separate key more. In fact, since my main Extend is LeftAlt, I am inclined even to use CapsLock as Extend2.

    Last edited by stevep99 (27-Feb-2018 12:02:59)

    Using Colemak Mod-DH with some additional ergonomic keyboard mods.

    Offline
    • 0
    • Reputation: 87
    • From: Oslo, Norway
    • Registered: 13-Dec-2006
    • Posts: 4,472

    Maybe like this?

    | J    | L    | U    | Y    |
    | K    | N    | E    | I    | O    |
    | M    | H    | ,    | .    |
    | Spc  |
    | WhUp | LeUp |  Up  | RiUp |
    | WhDn |  Le  |  Dn  |  Ri  |  M3  |
    |  M1? | LeDn |  M2  | RiDn |
    |  M1  |

    Acceleration on Shift sounds nice to me!

    Shift-click M1 on M? I think M1 on Spc is good, as it's very easy to hit with the thumbs. But I'd also keep the left-hand home row mods for the mousing layer.

    A separate Extend2 key would be nice, but I don't feel I have one to spare... And as we approach Extend3 and maybe Extend4, the problem compounds. I use Extend2 for NumPad, so my mousing layer if I make one would have to be one of the latter.

    Last edited by DreymaR (27-Feb-2018 13:16:05)

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 0
    • Reputation: 48
    • From: UK
    • Registered: 14-Apr-2014
    • Posts: 638

    Good point about using space, I hadn't considered it. Might give it try with your pattern.

    Update: Yeah, it seems nice, think I'll keep it like that.  It's also possible to use S,T as Shift/Control in that layer as well, to do mouse-selections, and of course it's worth keeping cut/copy/paste too. Although obviously it's easier to do all that with normal Extend.

    How many Extend layers could one possibly need??

    Last edited by stevep99 (27-Feb-2018 19:19:36)

    Using Colemak Mod-DH with some additional ergonomic keyboard mods.

    Offline
    • 0
      • Index
      • General
      • Mapping one key to two modifiesr [xkb]