There are several symptoms when this happens, you can experience phantom keystrokes or the way I discovered this was happening which is trying to Stream Skyrim from a Windows PC to my linux machine over steam. When I went into “BigPicture” mode on my linux machine and looked at the settings, inside the Add/Test menu item under Controllers there was a Controller listed, even though there wasn’t one connected. This was causing Skyrim to set the bGamepadEnabled=1 when i launched, which made the mouse/keyboard unusable.
Down the rabbit hole of google search results and forums posts. I came across this github repo, https://github.com/negativo17/steam instead of trying to run the patch or use his version of steam, I took a look around.
There is a file in the repo https://github.com/negativo17/steam/blob/master/51-these-are-not-joysticks-rm.rules. If you put this file in
/etc/udev/rules.d/directory and reboot it may fix your issue.
I use the MS Sculpt M/K combo which has a Vendor ID of 045e and a Product ID of 07a5. So i needed line 24 and 25 to tell joydev.c of the linux kernel that my mouse and keyboard were not a joystick/controller