(I'm on Arch Linux)

I want to swap esc and capslock but only do so for my laptop's built-in keyboard and not my plugged in extra keyboard. Is such a thing possible? If yes, how?

1 Answer 1


Today, basically all keyboards (even laptop built-in keyboards) identify as HID devices towards the kernel. You can check this for your laptop using dmesg after boot.

There's a very little known feature in the HID kernel layer which allows to map scan codes (a number assigned to each key, potentially different for different keyboards) to key codes.

I do not know of a single readily-available command line utility for this, but it is integrated into udev in form of a hardware database.

And fortunately this database is by device, so it fits exactly your use case: You can have key swapping for one keyboard, but not the other.

Details can be found e.g. here, or google "udev hwdb" or similar. Setting everything up will require time and fiddling.

You must log in to answer this question.

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