Keyboard keys randomly stop working in apps but work again later

I’ve been having an ongoing issue with my keyboard and I’m not sure what’s causing it.
Some keys randomly stop working in different apps, but then work again later without me doing anything.
Has anyone experienced something similar or found a fix for this?
.