What is the function of the modifier keys in xmodmap?

7

1

When I run xmodmap, I get something like this

shift       shift_l (0x32),  shift_r (0x3e)
lock      
control     control_l (0x25),  control_l (0x42),  control_r (0x69)
mod1        alt_l (0x40),  alt_r (0x6c),  meta_l (0xcd)
mod2        num_lock (0x4d)
mod3      
mod4        super_l (0x85),  super_r (0x86),  super_l (0xce),  hyper_l (0xcf)
mod5        iso_level3_shift (0x5c),  mode_switch (0xcb)

I get the shift and control groups. But what are the other mod1, mod2, mod3, mod4 for?

It seems that you can only use two modifiers as follows anyway:

keysym <keysymname> = <key> <shift+key> <mode_switch+key> <mode_switch+shift+key>

Why can't I set something to <mod4+key>?

user128063

Posted 2016-03-25T15:28:58.003

Reputation: 221

I'd love to know how to set <mod2+key>... Did you find a way through yet? – Matthieu – 2016-11-02T10:43:18.147

No luck :( probably have to wade through code or find a responsive IRC channel. I just use my window manager to manage shortcuts now – user128063 – 2016-11-05T14:13:30.193

Answers

2

X11 provides 8 modifiers to any keypress. You seem to have a fairly conventional set, where shift, control and lock have the obvious mappings.

mod1 usually represents Meta or Alt, and mod2 to mod5 are available for whatever other modifier keys your keyboard has, often labelled Super or Hyper. Usually these are not used for entering characters, but are interpreted by applications - for instance, in Emacs, I make Super+TAB equivalent to Meta+TAB:

(define-key function-key-map (read-kbd-macro "s-<tab>") (read-kbd-macro "ESC TAB"))

If you want your keyboard to generate characters using these modifiers, then xmodmap is not really capable enough, and you'll want to look into setxkbmap instead. That's a topic that's too big for this answer, though.

Toby Speight

Posted 2016-03-25T15:28:58.003

Reputation: 4 090