1

I'd like to change the right control key along into a "super" modifier and right alt key into the "alt" modifier (not the Meta) in Solaris and Linux (as I know how to do that in Windows using AutoHotKey). I know how to do this:

(define-key local-function-key-map (kbd "<rwindow>") 'event-apply-super-modifier

But I don't know how to specify the right control key or right alt key (which are more convenient to type than the Windows keys). If that can be done straight in emacs (and avoid AutoHotKey in Windows as well) that would be great. Otherwise I'd like to know what can achieve in Solaris and Linux the same think that AutoHotKey does.

  • What do you mean by "right left alt key"? I am assuming you mean either right or left. Can you edit your question to clarify? – lzam May 29 '15 at 3:19
2

I don't know of any way to do this in Emacs. As far as I know, the two Ctrl keys are treated the same. For some OSes, there's an option to change the keysym for R-Alt but I don't know of one for X Windows. Note that you can use the x-alt-keysym variable to change the keysym for both Alt keys.

You can change the modifiers bound to each key in X Windows using xmodmap. The Arch Wiki article covers its use. Basically:

  • Type xmodmap -pm to print a list of modifiers and the keys assigned to them, eg.

        shift       Shift_L (0x32),  Shift_R (0x3e)
        lock
        control     Control_L (0x42),  Control_R (0x69)
        mod1        Alt_L (0x40),  Alt_R (0x6c),  Meta_L (0xcd)
        mod4        Super_L (0x85),  Super_R (0x86) ....
    
  • Then create a file that clears and rebinds the modifiers you want to change. Eg. to change R-Ctrl to super, this should work:

        clear super
        add super = Super_L Super_R Control_R
        clear control
        add control = Control_L
    
  • To handle, the Alt keys, you could use:

        clear meta
        add meta = Alt_L
    

    That should cause Emacs to find the existing meta modifier and stop treating the Alt keys as meta by default. Then the R-Alt key will be available as an alt modifier for use in Emacs (and the L-Alt as meta). I've never tried this.

    If that doesn't work, you'll have to pick an unused modifier to bind R-Alt to, eg. hyper. Then you could use that in Emacs bindings.

  • You can activate the changes saving your file as ~/.Xmodmap and running

    xmodmap ~/.Xmodmap
    

    In many desktop environment, ~/.Xmodmap will be automatically run at startup. If not, you'll have to run it in your ~/.xinitrc file:

    if [ -s ~/.Xmodmap ]; then
        xmodmap ~/.Xmodmap
    fi
    
  • xev shows different symbols (here at least) for left/right control, alt keys. It has done that for every system I have used with X that has those physical keys. – Thomas Dickey May 29 '15 at 0:49
  • @Thomas Dickey: Different keysyms? Different to mine, or different to each other? Mine are different for the left and right key of each type as well. They're assigned to the same modifiers, though. Ctrl_L (FFE3) and Ctrl_R (FFE4) are assigned to the control modifier. Alt_L (FFEA) and Alt_R (FFE9) are assigned to the mod1 modifier. – pyrocrasty May 29 '15 at 1:44
  • Thanks! I don't think I have X available on the linux machines (I'll be using them over ssh) - which I failed to mention - but I appreciate your answer. – Adrian Chira May 29 '15 at 16:18

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.