I find lots of examples on how to set the mod key in xmonad, but how do I add a second mod key?


You can use xmodmap to add a second key to e.g. Mod1, so that pressing either would work with modMask = mod1Mask.


You can just or the keys together... watch:

$ ghci
> :m + XMonad
> :t (.|.)
(.|.) :: (Data.Bits.Bits a) => a -> a -> a
> :t mod1Mask
mod1Mask :: KeyMask
> :t mod2Mask
mod2Mask :: KeyMask
> :t mod1Mask .|. mod2Mask
mod1Mask .|. mod2Mask :: KeyMask

So as you can see you OR two key masks together to get the result that you desire. That's all it takes so you just use it like the last line there.

myAwesomeModMask = mod1Mask .|. mod3Mask
-- or whatever you want it to be

And that is all that there is to it.

Edit: Ah wait, you want two different keys to independently act as the Mod key. That is currently impossible I think as the code currently stands. Solution: check out the source and edit it yourself and then cabal install it again; it would be a small change.


Just to expand on Daniel Schoepe's answer, I do this in xmonad using the super key (the windows key) but I don't set anyting in xmonad.hs (other than setting modMask = mod4Mask). Using xmodmap I've set the left control as a second super key with the following in my .Xmodmap file:

remove Control = Control_L
keysym Control_L = Super_L
add Control = Control_L

You can also use xmodmap to swap capslock and control, set right control to be super as well, etc, but mind that the changes will only work in X, not in virtual terminals.


You may bind mod keys other mod1 by editing your xmonad.hs modMask value.

An example, binding to the mod4 (often 'Win') key:

import XMonad

main = xmonad defaultConfig
         { modMask = mod4Mask
         , terminal = "urxvt"
  • This binds modMask to only the win key. I'm looking to bind it to two keys so pressing either of them works – Arthur Ulfeldt Nov 11 '09 at 19:26
  • Sorry but I dont know how to do that either – Avis Nov 12 '09 at 3:53

You can bind both your modMask choices to the same action. This may be achieved by cotcatMaping on your initial (key,action) List.

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.