|Try blowing compressed air on your USB ports (make sure the PC is off when you do it). |
If that doesn't work, then you've already given yourself the answer - you bought a new keyboard and it has the same problem, that means the motherboard isn't transmitting your keystrokes to the hard drive via the RAM.
As a result, you will need a new motherboard. If your computer was bought through a manufacturer, check to see if it's still within warranty. If it is, you can get a motherboard for free and probably have someone install it for you for free as well.
Otherwise, you'll have to investigate costs and see if you want to buy a new motherboard plus the costs of labor or just cut bait from the PC and get a new one.