According to Apple
"Rule Out Software
Confirm that the problem is not caused by a software conflict or corruption, which will usually affect both keyboard and mouse, and often intermittently. Note, however, that if the keyboard power button cannot be used to power on the iMac, the...