All XMonad shortcuts use the modifier key modMask, which by default is bound to the left Alt key. Often however, we need another key.

XMonad has a so-called “modKey”. This is just one of the keyboard’s modifier keys ➡ Wiki modifier key chosen to be involved in all XMonad’s built-in shortcuts to not conflict with other shortcuts of our operating system.

This “modKey” appears in shortcut configurations as modMask in

((modMask .|. shiftMask, xK_Return), spawn "xterm") 

in native Haskell notation or as M in

("M-S-<Enter>", spawn "xterm")

in an Emacs-like “EZ” notation. Both definitions represent a shortcut that opens a new terminal window when we press Mod + Shift + Enter at the same time.
More: In-depth XMonad shortcuts
See: XMonad shortcuts cheat sheet
See: XMonad shortcuts source code
See: The best editor: (Doom) Emacs

Change the modifier key

modMask usually is the left Alt key, but to avoid conflict with other apps like Emacs, that also rely heavily on that key, many set it to the windows key:

-- myConfig :: XConfig
myConfig = def
  , modMask = mod4Mask -- windows key
Custom variable for our configured XConfig value.
The default XConfig value as configured by the XMonad authors. ➡ Source code
def { modMask = mod4Mask }
Haskell syntax to create a copy of def with our modifications. Here we replace the old modMask value with mod4Mask, which represents the Win key. ➡ Override notation

With this simple change we have “moved” all shortcuts to other key combination that hopefully don’t conflict with existing apps anymore. Of course we can choose any other modifier key.
More: In-depth XMonad shortcuts


The keyboard’s modifier keys are named mod1Mask, mod2Mask, etc. in XMonad ➡ Wiki modifier key and are usually bound to:

mod1Mask Left Alt key.
mod2Mask Numlock Num key.
mod3Mask Undefined.
mod4Mask Win key, also called “Super key” in Linux.
mod5Mask “ISO_Level3_Shift” key.

In a terminal you can run

$ xmodmap
mod1        Alt_L 
mod2        Num_Lock 
mod4        Super_L,  Super_R
mod5        ISO_Level3_Shift 

to find out to which keyboard key is assigned to which modifier key in your linux distribution.

Tags: xmonad shortcut haskell key binding keymap modmask

Malte Neuss

Java Software Engineer by day, Haskell enthusiast by night.

Other Posts In Series

Just Enough Haskell For XMonad

How To Configure XMonad Keyboard Shortcuts

In XMonad any action is done with a keyboard shortcut: start an app, switch between workspaces, change the layout of your windows, running scripts, etc. This is more efficient than using a mouse, and highly customizable.

Read More

Just Enough Haskell For XMonad

How To Configure Workspace Shortcuts

The keyboard shortcuts in XMonad to manage screens, workspaces and windows often use hardcore Haskell syntax that may be difficult to understand. But it’s just unfamilar.

Read More

Just Enough Haskell For XMonad

Better XMonad Keyboard Shortcuts: EZ

Writing keyboard shortcuts for XMonad in native Haskell is straightforward. Yet there is an even shorter, “EZ” notation.

Read More