Keyboard stopping: don't know how to troubleshoot

My laptop keyboard apparently randomly (although it does tend to happen during full screen streaming), just stops working, leaving me with just the touchpad. When the keyboard stops working, I have to exit from the account (using the touch pad) and then the keyboard works again and lets me type the password. Not only I don’t know how to solve the problem, I cant even fathom how to troubleshoot it (cant insert command lines when the keyboard is blocked). Any help would be appreciated