I've run into this problem a few time in a school full of iMac computers. Randomly someone can't logon and the keyboard appears to type some sort of unrecognized characters. I've discovered that a simple fix is to merely RUB MY HAND VIGOROUSLY OVER ALL THE KEYS. Voila! Working again. If there was a key that was stuck that I couldn't see, rubbing over all of them made it work again.