Was the other keyboard some USB keyboard or Bluetooth or ???
When the USB or such keyboard does this it's usually software.
When the replacement keyboard does this, it could be hardware such as a bum motherboard.
Let's hear exactly what the test was.
I have a Mac running OS X Yosemite, version 10.10.5
The keyboard recently, inexplicably started typing extra letters.
For example, when I type "now," what appears is "bnow." When I type "the," what appears is "tyghe."
I tried using a different keyboard, to no avail. Also tried rebooting in safe mode, which did no good.
Can't find any solutions online, so I guess I'll have to lug it to a repair shop. Sigh.