I think I've found the cause of the problem. It seems to the be DOS mouse driver, or the mouse I'm using. Because if I don't use the mouse to play, I'm not experiencing the issue.
I've tried two different mice so far.
Mouse 1: Microsoft Compact Optical Mouse 500 - This mouse makes the keys "stick" some times.
Mouse 2: Logitech G403 - Using this mouse I loose the keyboard and mouse after a few seconds, which leaves me unable to do anything but reset the computer.
So any advice to what mouse driver to use, which can handle modern optical mice. Or an easily available and affordable mouse which will work well in DOS?
EDIT: I went out an got a cheapo optical USB mouse, with a PS/2 adapter and the problem still remains. The mouse driver is CuteMouse v1.9.1 alpha 1 (downloaded from PhillsComputerLab)
I'm going to try updating the driver and play around with some settings.
EDIT2: CuteMouse v2.1 beta 4 has the same issues and they seem to occur more frequently.
EDIT3: I'm at the end of my rope here. Not sure what to do anymore. I've tried yet a different mouse driver, one from Logitech. Iv'e tried two different keyboards. I've tried using the PS/2 adapter on the keyboard instead of the mouse. (Yes, I used the PS/2 keyboard port.)
The issue still remains. If I use mouse and keyboard at the same time to play, the games (DOOM and Duke 3D) will randomly walk in one direction by it self, even if I'm not pressing any keys. The only way to stop the walking is to press the key that corresponds with the direction the game is walking.
The motherboard I'm using is the MSI KM2M Combo-L, which I've updated wit the latest available BIOS.
EDIT4: This seems to only be an issue in MS-DOS mode. If I play the games from Windows there's no issue.