Borrow a friend's keyboard and try if the PC still shuts down.
If it does not, then the keyboard could be the problem...
If it still shuts down, and assuming your keyboard has a PS/2 connector, try a USB keyboard and check if the problem was with the connector...
If that does not solve your problem, then try reinstalling Windows...