Wrong keycode on macOS. How to fix?
It sounds like your machine thinks you have an ISO keyboard (which has an extra key to the left of z for grave/tilde) instead of ANSI. Some possible fixes are at

http://m10lmac.blogspot.com/2009/12/fixing-keyboard-type-problems.html