On my external mechanical keyboard the Super/Windows/CMD key is between Ctrl and Alt, but on the Mac keyboard it's between Alt and Space.
Can I swap CMD and Alt only on the external keyboard?
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.Sign up to join this community
There is a section dedicated to this under → System Preferences → Keyboard:
Open Modifier Keys… and reassign them from here:
These settings are specific to each external keyboard you have connected. They will “stick” between reboots, as well as whenever you unplug an external keyboard and plug back it in.
The built-in macOS solution did not work for me because there's no option to select a different keyboard.
For macOS Sierra to Mojave (current release as of right now), Karabiner-Elements does exactly this. You can find the GitHub page at https://github.com/tekezo/Karabiner-Elements.
It runs in the background. In the preferences, you configure the target device for modification and it remembers the settings. I have a bluetooth keyboard (Logitech G613) where only that keyboard's CMD and ALT are swapped. I use this keyboard between my PC and Mac.
Below you see an example of Karabiner-Elements v12. It doesn't show my G613 because it is not connected right now.