I can probably help you out.
But I'll need more info.
Is this an issue with your USB ports? Are they working for everything else? (Examples being external hard disks and iPhone, etc)
If they are, then there's two other things to check:
Your keyboard (What kind of keyboard? M-Audio? Novation? AKAI?). Is it bus powered, or does it have it's own power supply? If so. Make sure that it is receiving power from the iMac. My M-Audio Axiom had an issue with a loose connector on board that needed a quick solder, loose USB meant no power. It could be a case of this.
Is it showing up in MIDI-Studio? If so, make sure it is routed correctly in there. Some funny things can happen, especially if this is a lower end keyboard, and you may just need to nudge it in the right direction.
If it powers on and still isn't communicating (with what software? Ableton? Logic? Reason?) make sure it is recognized by the software. Reason will ignore keyboards until you tell it to pay attention in Preferences. Ableton too.
If it STILL won't budge, try using a powered USB hub. I know there was an issue with the first generation of Lynnfield (Core i3, i7, i5) that the USB host controller didn't play nicely with certain music peripherals. (Huge nightmare getting a Launchpad to act right.) USB hubs have a way of magically fixing things sometimes.
If you STILL aren't any farther on, then I would suggest trying another keyboard. If that one works, and all the above hasn't, then you likely have a dud MIDI controller. Warranty it or turn it into an art piece or something.
Hope I could help!
With a little more info, I can probably hold your hand a little further on the matter.