• You are not logged in.
  • Index
  • Technical
  • linux: how to map, eg, alt-n to ctrl-leftarrow?

    linux: how to map, eg, alt-n to ctrl-leftarrow?

    • Started by chema_quinn
    • 4 Replies:
    • Reputation: 0
    • Registered: 14-Mar-2013
    • Posts: 10

    I'm the creator of the qwpr layout. One of the features of this layout is that caps-lock accesses a layer that includes basic ascii punctuation and arrow keys. The left and right arrow keys on this layer are, by default, word-by-word rather than letter-by-letter; that is, for example, ctrl-leftarrow rather than just leftarrow.

    I've been able to have this functionality on Mac (through karabiner elements) and Windows (through pkl). On the rarer occasions I've used linux, I've used xmodmap to just have eg leftarrow, without the control.

    However, I'm now going to start actually programming on a linux system. So I need my full keymap.

    I've done some basic searching, and it doesn't look as if there's a clear howto that answers my question. I'm sure I could figure it out with enough trial and error, but I would also guess that someone in this forum has already solved it. So:

    On linux, how can you get modifierA+letterkey to remap to modifierB+arrowkey? I'm open to solutions using xmodmap, xkb, both, or something else.

    Thanks!

    Offline
    • 0
    • Reputation: 210
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,343

    The solution can be found if you read my symbols/extend file in the BigBag for XKB well enough. TTBOMK, you need to map both an ouput and an action (with the right modifiers – your "modifierB" active) to the right key state (the <key> "modifierA" position). I may be wrong but I don't think xmodmap can handle such advanced cases.

    Last edited by DreymaR (08-Apr-2020 09:56:42)

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

    Offline
    • 1
    • Reputation: 0
    • Registered: 14-Mar-2013
    • Posts: 10

    Thanks, DreymaR, for that reply, and for all you do for the community!

    I'm sure the trick is, as you say, somewhere in https://github.com/DreymaR/BigBagKbdTrixXKB for me to copy. But there's so much there, it's hard for me to know where to look. Can you give me any hints? If you want to go above and beyond, you could tell me which key combination there does something similar, and which file to look in to find it being done. If you're too busy to go that far, more hints in that direction would probably be plenty.

    Offline
    • 0
    • Reputation: 210
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,343

    I know, it's a lot. You should look in this file, the symbols/extend file. Key <AB01> shows how I implemented Undo as Ctrl+Z. I've set, e.g., level 5 to redirecting that key with Ctrl active and the level 5 mod inactive. (For Extend I map levels 5–8 and leave levels 1–4 alone.)

        key <AB01> { symbols[Group1]=[ NoSymbol , NoSymbol , NoSymbol , NoSymbol ,
                       Undo                 , Redo                  , // Undo/Redo
                       Undo                 , Redo                 ], // Undo/Redo
                     actions[Group1]=[NoAction(),NoAction(),NoAction(),NoAction(),
          Redirect(key=<AB01>,mods=Control,clearmods=LevelFive), Redirect(key=<AB01>,mods=Shift+Control,clearmods=LevelFive), // Ctrl+Z
          Redirect(key=<AB01>,mods=Control,clearmods=LevelFive), Redirect(key=<AB01>,mods=Shift+Control,clearmods=LevelFive)] // Ctrl+Z

    Now, Alt as such isn't a level. But AltGr is; that is, the RAlt key on Euro boards is usually set to a level switch for level 3 (and 4 with Shift). I think you have to use that functionality, which is integral to both my Colemak and the standard Colemak. Then set your level 3 mapping for the key to a redirect/mods/clearmods action as above.

    Last edited by DreymaR (14-Apr-2020 10:01:39)

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

    Offline
    • 0
    • Reputation: 0
    • Registered: 14-Mar-2013
    • Posts: 10

    Thanks! I'm away from the linux box at the moment, but I'll get it fixed and post my solution when I'm back to it.

    Offline
    • 0
      • Index
      • Technical
      • linux: how to map, eg, alt-n to ctrl-leftarrow?