Fix inverted keys on a Mac
Symptoms
On your ISO external keyboard (European, with the big Enter key), the characters on the left of 1 is inverted with the one on the right of the left Shift.
This usually means that macOS has not identified your keyboard type correctly. You can check this with the Keyboard Viewer:
When pressing a key on your external keyboard, it will update to what macOS thinks your keyboard looks like. Here the keyboard had been identified as a Macintosh one instead of a standard one.
Fix
It looks like the selected input source can interfere with the automated keyboard identification. Identify the keyboard manually if that’s the case.
Start the Keyboard Setup Assistant
Only if you cannot see this option, you may need to remove the keyboard type preference file and reboot the Mac. For example, in a terminal:
sudo rm /Library/Preferences/com.apple.keyboardtype.plist
Double-check the keyboard type
Follow the Keyboard Setup Assistant instructions, but double-check that the keyboard is identified correctly.
If you are using a standard European PC keyboard, it should be identified as ISO/IEC 9995
.
If you are using a European Macintosh keyboard, it should be identified as ISO/Macintosh
.
Skip the automated detection if it is not working
If the keyboard is not identified correctly, go back and press random keys until you can skip the automated detection.
Now you can choose the correct layout, here a standard European PC keyboard (ISO/IEC 9995).
Hopefully, the keys are now behaving like expected, both on your external keyboard and your MacBook one. The Keyboard Viewer layout should match the one of your physical keyboard.