When the issue occurs, try executing a command containing the "Windows Miscellaneous Functions" action set to the "Reset Keyboard Shortcuts" option.
If a message appears in the log about an invalid hook handle, wait a few seconds, then execute the command again.
If the keyboard hook (the Windows API component used to receive and handle keyboard input) is getting broken by another application, that'll reinstate the hook and allow keyboard input to work, until it's broken again.