2

I'm trying to simulate numeric keypad keys on the main keyboard but am struggling with xkb.

How do I to convert a <LWIN> + <AD07> into a 'Left'? (AKA Super + u)

It needs to play nice with Shift, Ctrl (and ideally Alt too).

The closest I came was:

    type "wkafk1" {
        modifiers = Shift+Super;
        map[Shift]= Level2;
        map[Super] = Level3;
        level_name[Level1] = "Base";
        level_name[Level2] = "Shift"; 
        level_name[Level3] = "Fn"; 
    };

...
    key <AD07> {
        type= "wkafk1",
        symbols[Group1]= [               u,               U, Left ]
    };

But Shift+Super+u isn't handled.

This one was close too:

    type "wkafk1" {
        modifiers = Shift+Super;
        map[Shift]= Level2;
        map[Super] = Level3;
        map[Shift+Super]=Level4;
        level_name[Level1] = "Base";
        level_name[Level2] = "Shift"; 
        level_name[Level3] = "Fn"; 
        level_name[Level4] = "Fn Shift";
    };
...
    key <AD07> {
        type= "wkafk1",
        symbols[Group1]= [               u,               U, Left, Shift+Left ]
    };

But it didn't compile because I don't know how to emit a modified symbol (Shift+Left is not allowed).

Do I need an 'interpret' statetment with action= RedirectKey(...) ?

2

Thanks to some prior art, here are the steps:

  1. xkbcomp $DISPLAY custom.xkb
  2. Edit the custom.xkb ...
  3. Add this to end of section: xkb_types "..." {

    type "wkafk1" {
      modifiers = Shift+Super;
      map[Shift] = level2;
      map[Super] = level3;
      map[Super+Shift] = level3;
      level_name[Level1] = "Base";
      level_name[Level2] = "Caps";
      level_name[Level3] = "Arrows";
    };
    
  4. Replace key definition <AD07> in section: xkb_symbols "..." {

    key <AD07> {
        type= "wkafk1",
        symbols[Group1]= [ u, U, NoSymbol],
        actions[Group1]=[ NoAction(), NoAction(), RedirectKey(key=<LEFT>,clearmods=Super)]
    };
    
  5. xkbcomp custom.xkb $DISPLAY

This works with Shift and Ctrl key combinations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.