Hello! My name is Mustafa, and I am an Independent Advisor as well as a long-time Microsoft user. I'm sorry that you are experiencing this issue, and I am hopeful that I will be able to help you find a satisfactory solution.
can you make sure that you have the latest windows version, and keyboard drivers on your device?
go to settings> windows update> update
go to device manager> keyboadrs> update the drivers
Search for find and fix keyboard problems on your device and run the troubleshooter to see if it can find any issues.
Also, connect an external keyboard to see if it stops working as well, if the external keyboard doesn't stop working then it is a hardware issue and you should get it replaced.
Please let me know if this doesn't work or if you need further assistance.
Warm Regards,
Mustafa