Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

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

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

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"
share|improve this answer
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 must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .