You should check all keys with Notepad or whatever to ascertain which keys are most affected. Obviously if it is "gamer keys" that would point to a used keyboard, maybe with new keycaps put on.

Only you will know if you bought from a decent PC parts supplier.

You should not have to clean a new keyboard, a membrane type maybe impossible to clean, it maybe the printed contacts at fault/corroded or whatever.

Helmut said:
I would suspect 2 potential problems from what you are saying The Keyboard itself and the USB socket.
How can you say that it can be related to the USB socket, cable etc if only some keys have problems?
It is perfectly in order to suggest USB connectors leads etc as well as the Keyboard itself, the OP needs to do some logical testing themselves.

"the reason I mention this is that I plugged a USB flash drive and the PC did not read it, so pulled it out and reinserted it and it showed (this was with another port all of which is for the motherboard so just thought I'd mention that)."