There was another OSX user who was having some keyboard problems. It wasn’t the exact same problem as this, but maybe the information is still relevant. He managed to solve his keyboard problem by logging out of his OSX user account, into a different user account, and then back into his original account. After doing that, the keyboard issues were gone. Perhaps you can give this a try?