Frankly, all those symptoms sound like the keyboard itself is at fault.
The fact that it's a separate standalone keyboard, and you tried it on two different computers and got similar results is really pointing the finger at the keyboard. At first I thought you were talking about the rMBP's builtin keyboard, but then I realized I'd misinterpreted "It does the same thing on a mac mini".
Just because the problem is intermittent doesn't eliminate the keyboard as a possibility. Grunge buildup and electrical miscontacts can be intermittent.
If it were wireless I'd say "check the battery", or even "check the battery contacts for corrosion". The fact it's wired USB eliminates that.
Simple and obvious solution: get a new keyboard.
If you don't want to do that right away, try borrowing a USB wired keyboard from someone. If that works, it's pointing even more strongly at the keyboard itself being the problem.
There may be something fixable if you opened the keyboard case and cleaned it out really well, but unless you're halfway skilled with cleaning electronics, that's still a gamble. You could still try it after you get a new keyboard, when there's nothing to lose if a cleanup goes wrong. Or you could risk it without having a new keyboard at hand, as I assume the rMBP builting keyboard still works.