It may not be hackers. It looks like it is, but it may not be.
It could be that your keyboard is playing up. Have you had a spill on it? Is it full of crud? Closing the lid of the laptop may be putting enough pressure on the keys for random presses to be happening (sounds like the bottom row of the keyboard is being pressed - CTRL-ALT and Arrow keys rotate screen for example.
Does it do it if the screen is not closed?
You say 'They were trying to setup a VPN' - was there any typing? If you can see that someone has typed something, then yes = hacked. If not, then I'd be guessing the keyboard is faulty.