The links are below:
For future reference, those are Apple knowledge base articles. Apple has a lot of very good articles that one accesses in the support part of this web site.
P.S. Doing those two things may not fix the problem, but they will not hurt either.
I had the same problem with my 27" iMac medio 2010.
I then called Apple and they had me shut down the computer, unplug the power cord for about 15sec.
Plugged it in again and then wait for another 5sec.
Then start up again.
When it was booted I went to the Bluetooth icon in the top to reconnect the mouse and keyboard and "viola" it simply worked again.
Don't know if it'll help you, but it is worth trying.
I had the same problem with pairing my silver wireless keyboard with my Imac. Sometimes it would find the keyboard but would not enter the code until I realized that it was paired with my ipad sitting on my desk next to the computer. Once I turned off Bluetooth on the ipad I was able to repair it with my imac no problem
Something I learned:
Make sure NOTHING else is paired or on bluetooth!! Turn off all other bluetooth devices in the area, even if you think they are too far away.
I had this same problem. I just could not get my Keyboard to go into discoverable mode. I realized that I had paired my keyboard to my iPad a few weeks prior to the battery going dead. I was able to use it on my computer and my ipad for those weeks, but after the batteries went dead I couldn't re-pair it to my iMac.
It took me 45 min to remember I had it paired to my iPad. Even though the iPad was in the other room, 20+ feet away and through two interior walls it was still reading my keyboard. I told the iPad to forget the keyboard and it worked like a charm immediately.
Just when I was ready to get ****** off at Apple I realized it was my own fault. I swear that happens every time...
kind of having the same issue...keyboard is sometimes not recognized. bluetooth is on, and the mouse shows up as paired, but when i open the keyboard preferences it says "no keyboard found" and just searches endlessly. most of the time it is no problem but in the last few weeks it has been toally nonresponsive 2 or 3 times. any ideas? i'll try pram/smc, i've tried unplugging and rebooting, batteries are brand new, and i only bought the computer over the summer so i don't think the aluminum foil trick will work. thanks.