Remap Keyboard Keys on a per Device Basis
For this solution, systemd is required.
To do that we first need to find the ID of the key in question - say currently it is left alt. We need to run evtest as root and select the keyboard from the device list. Then press the key you want to change - left alt. You get two lines of output, the last number of the top line gives you an id of the key (for example 38) and the bottom line tells you that the key is mapped to.
Now we need to create a file in /etc/udev/hwdb.d/, such as /etc/udev/hwdb.d/99-keyboard.hwdb:
evdev:name:{keyboard name}:*
KEYBOARD_KEY_38=leftmodThe keyboard name is the same as for the device select options in evtest.
To update the configuration, you need to run:
sudo systemd-hwdb update
sudo udevadm trigger /dev/input/event*