When I was working in electronics and we had something weird like that, we’d blame it on invisible dendrites.
The fix was to blast the malfunctioning item with compressed air, to blow away all invisible dendrites.
Usually worked. Give it a try, your keyboard could probably use a cleaning anyway.
AKA “tin whiskers”.