I doubt any restore (tablets and smartphones is reset) would likely not resolve this and take a lot of time. It does, sadly, sound like a hardware issue. Either the keyboard has a short in it that is causing the laptop to shut down or the motherboard has a problem.
I would start by trying to use an external keyboard (connected via USB) and see if the device stays on. If it does, then the problem is likely the attached keyboard itself and you would need to have it replaced. However, should it still shut down, then you are likely looking at a motherboard replacement.