I finally found the right way to remap keys in Ubuntu.
This only works for later versions of udev so check your version.
> udevadm --version
Should be 240+
> sudo systemd-hwdb update # if it's not
First find the keyboard to remap
> sudo evtest
pick the keyboard by event id. Note the id (say it's 4)
press keys you want to remap and note the 'value' on the MSC_SCAN line on the key you want to change
press the key you want to map to and note the KEY_XXXX code
We will need the modalias, so
> cat /sys/class/input/event4/device/modalias
Now you need to make a file
> sudo gedit /etc/udev/hwdb.d/10-my-modifiers.hwdb
Here is mine:
> sudo udevadm trigger