When you connect an Apple wireless keyboard to your computer or mobile device for the first time, you will need to type in a pairing code. Each individual keyboard does not have a unique pairing code that applies to just that keyboard. Instead, a new pairing code is generated each time you pair the device. So if you unpair your keyboard from your computer, you will need to find the new pairing code before the keyboard will reconnect with the computer.
Wireless keyboards use Bluetooth technology, which is a short-distance wireless format that can connect devices within approximately 30 feet of each other. This signal broadcasts and receives in all directions, so to specifically connect one device to another, they need to be "Paired." This pairing process lets the two units lock in on each other and ignore other signals. Likewise, other devices that are not paired will ignore your paired signal. For example, if you have a computer and an iPad with their Bluetooth functions turned on, neither will accept input from the keyboard until it is paired. Then, once you pair it with one device, such as the computer, the iPad will continue to ignore it while the computer accepts the keyboard input.
The pairing code for an Apple keyboard is also called a "Passkey." If you are pairing your keyboard to a Mac, this passkey is eight digits long. If pairing with an iPad, you will generally see a four-digit passkey. This is because it is the computer's or device's software, rather than the keyboard itself, which generates the code; however, the input from the keyboard is also considered, otherwise the computer would not know what type of device you were trying to pair. Any time you need to find a pairing code for a new or unpaired wireless keyboard, look to your computer or mobile device's Bluetooth screen rather than the keyboard's documentation.
Entering the Passkey
When your computer or device's software -- either the Bluetooth setting on the iPhone or iPad or Bluetooth Assistant on a Mac -- shows you a passkey, type this code immediately into your wireless keyboard. Press the "Return" or "Enter" key after the code, and do not press any other keys, either before or after you enter this pairing code. After the computer or device registers that your keyboard is connected, you can use the keyboard as normal.
Turning off the keyboard does not unpair it from your device, so will should not need to enter a pairing code each time you resume using the wireless keyboard. Instead, simply turning the keyboard on when your device's Bluetooth is turned on will cause the two to pair, although there may be some lag time before the devices recognize each other.