Keyboard starts acting weird on Windows 10

Hello everyone
Good morning to all.
I’m using my friend’s computer from the past few days ago.
From recently When I use a computer my keyboard randomly starts acting weird, just like? My keys still work fine but I can’t use them to type. For example, when I play a game I can’t use the game’s chat but I can use the keys to play the game without any problem. The caps key and alt-tab also work properly. It’s not only happening in games even if I open google and press on the search box then try to type it won’t work. Also when I open my pc I’m not able to type in my computer’s password, the keyboard having the same issue.
The only quick fix I found is restarting the pc and pressing the “I forgot my password button” waiting for the new screen to load then closing it, then finally being able to type again.
Why would it get fixed after I press the “I forgot my password” button and not anytime else?