Hello,
Thank you for posting in Q&A forum.
Please check if your computer has updated drivers, sometimes updating drivers can solve hardware problems.
Try connecting the mouse and keyboard to different USB ports to see if the problem persists.
If possible, try connecting the mouse and keyboard to another computer to determine if it's a hardware issue or one related to your computer.
The above are the basic troubleshooting steps. This problem may be caused by a variety of reasons. Please follow the following links to fix the problem:
[SOLVED] Keyboard Randomly Stops Working (2024) - Driver Easy
Keyboard keeps disconnecting in Windows 11/10 [Fixed] (thewindowsclub.com)
I hope the information above is helpful.
Best Regards,
Yanhong Liu
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.