Apple - Can you pair Mac AND iPad with same Apple Wireless Keyboard?
Yes you can.
First, make sure Bluetooth is turned off on your iPad. And enable it on your Mac (make sure the box that says "discoverable" is checked). Then turn on your keyboard and follow the steps to pair it using the Keyboard System Preference pane. Once the keyboard is paired, uncheck "discoverable" (which should remain off unless you wish to pair another device) and then turn off Bluetooth.
Next, head over to your iPad and enable bluetooth. Turn your keyboard off (hold the power button till the light glows and then dims). Turning it on again will get the iPad to pick it up and a prompt will ask you to enter a 4-digit sequence of numbers and the "ENTER" key. Follow the steps. Once that is done, it will be paired.
To use the keyboard on the iPad, make sure the device has bluetooth enabled and that your Mac has that service disabled (you should disable the service before trying to connect the keyboard to the other device).
I just tested it using my Mac and my iPhone 4 and it works perfectly. Sometimes the device takes a second attempt to locate the keyboard, but it does indeed work.
For those who are looking to do follow the accepted solution with the Apple Magic Keyboard: it is not possible. As @bmike points out, the firmware of the keyboards remembers the last paired device: Can you pair macOS and iOS device with same Magic Keyboard and switch between them?