I just went through something with my MacBook Pro 13" where I was using a USB mouse and a MIDI keyboard. I left the computer for a while and it went into sleep mode and when I came back to it, the machine was very slow to respond. I shut out of everything and rebooted only to find that neither my built-in trackpad or keyboard was working anymore. I plugged in my USB mouse and that worked, and then a USB keyboard and that worked, but no signal from my built-in peripherals.
I ran a disc repair, cleaned out everything I could, updated all software, etc. etc. -- nothing... until finally I read something about how Java can cause a problem. I then went into my advanced settings and deleted everything in Java and Flash security. Also making it very difficult for those two applications to save anything to my machine. Once I rebooted my keyboard and trackpad were fullly functional again.
Wanted to share this because it was such an unintuitive fix but my computer is back at full speed again.