Yes, I understand. The keyboard is connected to the motherboard via a cable internally. Sometimes that connection can loosen. If you are comfortable opening the laptop, it should be a simple matter to check the connection.
If you want to run a simple check to give you a better idea if it is hw or sw related, you can boot to safe mode and see if the problem continues. If it does, it is almost certainly a hw issue and we're back to checking the cable connection as a first step.