SOLUTION FOUND...
I had these same issues. I use a MacBook Pro, connected to a Thunderbolt display and extended keyboard. When I disconnected the MacBook Pro at the end of the day and reconnected the next day, the keyboard (which is always connected to the Thunderbolt display), would no longer function.
I read all the posts about this not-so-rare problem, and none of the solutions were long-term fixes.
I called Apple to discuss teh problem, but the person I spoke to was unaware of the problem. They had me try all kinds of things, such as hardware resets and reconficgurations of various types. In the end, they were scratching their heads and advised me to take it to the Apple Store.
I brought the monitor and keyboard to the Apple Store. They too were not very familiar with the issue. I told them to check out this discussion board. They kept my monitor for a few days, but told me they didn't need the keyboard.
Three days later they called to say that they couldn't replicate the problem, at which point I questioned them on why they wouldn't test the keyboard as I suggested as well. So I brought my keyboard and laptop in to show them the problem.
Long story short, they switched out the keyboard and the problem went away. This has always been an obvious step in the process of elimination to me, but what do I know?
Four weeks later, I am happy to report that the issue has never returned. It wasn't the cable, or the monitor.
IT WAS THE KEYBOARD!
If you are having this issue, don't waste your time with all these funky workarounds. (An extension cable may work—and hopefully long term— but there's a proper solution if you don't want to add ugly cabling to your desk). Take the laptop, monitor and keyboard to the Apple Store (make an appt first!), show them the scenario, and then suggest they swap the keyboard before doing anything else. They will give you a new keyboard if it's determined that the keyboard was faulty.
The end.