USB wired keyboard not working IMac
I have an apple wired keyboard for my Mac and a Macally mouse. They've worked fine up until about 2 days ago. All of a sudden the keyboard has stopped working, but the mouse still moves. So I moved the plugs into different ports and it fixed. The problem reoccured, but moving the plugs didn't work, so I restarted the computer. Sometimes the mouse doesn't work at all now, and sometimes the mouse works but the keyboard doesn't. I've tried just about everything; I know all of my usb ports function correctly. Everyone says to use a USB extension cable (which I have and it isn't working). I've even restarted the computer multiple times. I can't even get into my computer right now, so I would greatly appreciate any help!
iMac, OS X El Capitan (10.11.3)