I have an Apple keyboard that isn't recognized by my Mac
Have you tried re-running the Keyboard Setup Assistant? First, get macOS to "forget" your keyboard: 

sudo rm /Library/Preferences/com.apple.keyboardtype.plist

and then reboot your Mac. If it still doesn't recognize the keyboard, you can try manually running the setup assistant

sudo /System/Library/CoreServices/KeyboardSetupAssistant.app/Contents/MacOS/Keyboard SetupAssistant

to see if it detects any keyboards it's not sure about.