Hi everyone.
I have the same problem with my Bluetooth keyboard and tried hard to solve it. I have a late 2013 iMac running El Capitan, but the problem was there with the previous version of the system.
I have had my keyboard replaced by an Apple Store and this didn't solve the problem. So nothing to do with a faulty nor dirty keyboard. Of course, the batteries were replaced by fresh ones. An old wired keyboard, as well as an old first generation Bluetooth keyboard have been used without any problem. I also have a mouse and a trackpad connected through Bluetooth, without problem.
I have opened a case with Apple service which I contacted on the phone 4 or 5 times, and been told ultimately to bring the iMac back to the Apple Store. I was instructed to do a fresh reinstall of the system, which I did when back home. To no avail. Got back for a third time at the Apple Store where the tech said I'd probably be better wait for an update in the OS that would correct the situation.
Out of nowhere, I thought the problem could be from waking up the iMac using the keyboard, so for months now I always use the mouse to wake it up. And this seems to have cleared the problem. I have noticed that if I tap the spacebar to wake up the IMac, this will almost always provoke the syndrome of spurious characters sent to the Bluetooth buffer.
But then, there are instances where the problem rises up, even though I think (not 100% sure) I've waken the system using the mouse. I still have the case number at Apple, so I will give them another call and see if there are any new info in their database concerning this annoying problem. Keep you informed if anything interesting shows up.
-- Christian (B->