Pair bluetooth keyboard when not logged in
Solution 1:
Here is a solution as noted here: How to unpair keyboard without original computer
Their solution was to:
Disconnected everything USB, etc. from the computer.
Restart the iMac while putting the new/different keyboard into discovery mode, and wait for the iMac to detect it.
The deal is you have to unplug ALL USB devices, have your wireless keyboard and mouse turned on, and restart. The system sees that there are no input devices and searches for them. Then asks you to type a passcode and hit return.
Solution 2:
If you have the Apple Keyboard 2 which has the Lightning port on the back of the keyboard, all you need to do is connect the USB -> Lightning cord to the computer and it will just like a normal wired keyboard.
Refer to: https://support.apple.com/en-us/HT201178
Solution 3:
This is only true if you have already selected "check for bluetooth keyboard/mouse at startup" Otherwise you have to connect a USB mouse and keyboard
Solution 4:
I just had this frustrating problem. Simultaneously pressing the command key and the power button worked for me.