Quick question, have you cleaned the contacts and blown out the keyboard connector slot?
I have found mine to be a bit of a dust magnet and one occasion where the keyboard started to be a little intermittent found it was due to crud.
If you have a slightly unstable connection on the left hand side of the connectors, and if your keyboard is in the elevated not flat position, ALT-TAB 'ing may flex the contacts on the keyboard on the left enough to clear and reconnect. YMMV
Mine does this sometimes. I don't know what triggers it. It happens when it's coming from sleep. It was either when I attach it while it was sleeping or detach it while sleeping. I can't remember. It's easily fixed so I didn't bother