I would be surprised if this is a keyboard issue. "In the middle of playing games" is short hand for higher temps in cpu, mobo, and gpu. You need to put up your whole build including gpu, cpu, mobo, monitor, mouse, keyboard, psu, AND the cables that you're using to connect it all. For example, is keyboard plugged into desktop USB or into the monitor, etc. The age of the system. The operating system you're using.
You might also install CPUID on your computer and list the maximum temperatures reached "in the middle of playing games" -- that is, check CPUID soon as you can. The problem is it will reset if you reboot.
When it happens try using alt f4 to stop the game so you can look at CPUID or ctrl-shift-esc so you can kill the game in task manager. If that doesn't work just game for ten or fifteen minutes--get everything nice and warm, and then check your temps before it happens.
You can also run Unigine Superposition in "extreme" mode it will push your build pretty hard so you can see what the temps are doing. Maybe when it's done your keyboard will be screwed up as you report. But at least it will put you through a pretty hard bench mark where you don't have to actually be gaming (and therefore using the keys). Watch the temps and see what happens, how high they go. And you can check CPUID when done just leave it up when you initiate Superposition.
Random guess? You have an older system and the psu may be going, and in the process it may have fried your cpu.