If you have access to USB wired keyboard/mouse,
you can check into the settings and also fix them.
A good backup is to have these on standby.
Also to know what versions of the named products
you have is essential, since they did change over
time & too, people with new stuff mistakenly post in
older PPC-iMac forum, when theirs is an Intel-Mac.
See: pairing keyboard with iMac (general ideas)
https://www.google.com/#q=pairing%20keyboard%20with%20iMac
•Bluetooth: How to set up your Apple Wireless Keyboard:
http://support.apple.com/kb/HT1809
•Troubleshooting wireless mouse and keyboard issues:
http://support.apple.com/kb/TS3048
There are a few reasons why yours do not work,
and depending on the hardware, answers vary.
Good luck & happy computing! 🙂