My Windows 7 keeps clicking out of programs

Hey, my Windows 7 keeps logging out of my programs example: I'll be playing Minecraft and it'll go into the escape menu and act like I'm clicking out of Minecraft. Anyway, any help would be appreciated.
 
Could be malware of course, but best to just check the keyboard first. Is it a portable or a desktop? If a desktop is the keyboard attached wireless or by cord? Can you borrow another keyboard ?
 
Back