Remapping Capslock on Wayland

Here’s how to setup remapping CAPSLOCK on Arch/Wayland/Sway using the Dual Function Keys plugin from the Interception Tools library.

More specifically, I’m remapping CAPSLOCK to act as

  • ESC when pressed/tapped by itself
  • and as the Windows key if in combination with another key

I have the windows key setup as a modifier in the Sway window manager, to be able to position any application.

And I use ESC in vim to exit insert mode.

Previously, I used xcape on X11, however this won’t work on Wayland, and probably won’t be in the near future as per this discussion. Thankfully by intercepting udevmon you can create a mapping that works on both X11 and Wayland.

Setup Dual-function-keys


  1. First install the plugin
sudo pacman -S interception-dual-function-keys


  1. Create the mapping file i.e in sudo nvim /etc/interception/dual-function-keys/capslock.yaml
# config for
# keycodes from
    # remap capslock
    # tap capslock for escape
    # tap capslock for windows key
  1. Create the udevmon configuration sudo nvim /etc/interception/udevmon.d/capslock.yaml
  • you can the NAME of your keyboard with sudo libinput list-devices | grep "^Device" | grep -i keyboard
- JOB: "intercept -g $DEVNODE | dual-function-keys -c /etc/interception/dual-function-keys/capslock.yaml | uinput -d $DEVNODE"
    # name of your keyboard device
    NAME: ".*"
    # NAME: ".*keyboard"
    # NAME: "SONiX USB DEVICE Keyboard"
    # NAME: "AT Translated Set 2 keyboard"
  1. Setup udevmon to boot with your system
sudo systemctl start udevmon
sudo systemctl enable udevmon

Now your keypresses should be remapped.

I got the gist of working with interception-tools from this blog A Guide to Switching From i3 to Sway - by Scott Gilbertson