I just resolved this same intermittent keys not working issue after having it go on for the past few weeks.
The computer is a MacBook Pro mid-2012.
With a Bluetooth keyboard it worked normally, even if the built in keyboard didn't.
I noticed I could sometimes fix the issue (for a short time) when I was resting my right palm on the case next to the trackpad or simply holding down keys that didn't work and pressing down in this area in places until they started working again, so I assumed then it had something to do with clearances. It didn't.
Since the problem was intermittent, and started shortly after I installed a new hard drive, at first I thought I'd done something with the hard drive installation, so I took it out and reinstalled (even though I've installed a few in the past and never had issues). The problem returned anyway, so even though pressing on the case over the new hard drive could sometimes get the keys working again (for a short time) this was all probably a coincidence and had nothing to do with changing the drive.
I read a lot of comments online about people removing key caps and scissor mechanisms and that the E key, even if it worked fine, was the culprit, causing issues with the other keys that followed it.
I'm not sure if that's the case, but I started prying the keycaps off for the E key and all the affected keys as I moved to the right: R, T, Y, U, I, O.
I blew everything out with compressed air as best I could, and also used tweezers to pull out any dust or fine dog hair I could see (I babysit a corgi, so there's often fine hair about).
I only had to fully remove the key cap and white plastic scissor mechanism under the E key to fix the problem, but I blew out/cleaned out the other keys while I was at it anyway.
If the problem returns, I'll try removing their scissor mechanisms and cleaning as best I can too.
That was the fix in my case after trying many things. Start with the E key and do a cleaning as best you can with the scissor mechanism fully removed, and see if it helps you.
You may have a different mechanism than the one I have in this video, but the idea is the same. It's debris trapped under the key cap that isn't blown out with compressed air that's causing the problem, and it's not necessarily the keys with the issue that cause it, but the ones "wired" in just before the issue starts.
https://www.youtube.com/watch?v=kh88cn_rtLo
Good luck.