Do you have access to an external USB keyboard & mouse?
If you do lets open up the system and do an inspection to see how it looks. Post pictures of anything that looks suspect. Dust it out using a soft brush and can'ed air.
What we'll want to do here is disconnect the keyboard and trackpad ribbon connections then using the USB keyboard & mouse see if you still encounter the problem. I'll warn you the system will ramp up the fans as they are going into Safe mode as the sensor or the trackpad will be disconnected when you pull its connection so don't let that bother you. We don't want to let it stay this way too long either as you don't want to over stress the fans.
Follow this IFIXIT guide: MacBook Pro 13" Unibody Mid 2010 Upper Case Replacement Follow the first three steps, then jump down to Step 11 pulling the trackpad connection (3rd image) and follow Step 12. Use care as you don't want to damage the connector or the ribbon cable. To ease it back in I use a small piece of electricians black tape folded over to make a pull stuck on the ribbon.
Is the system still wanting to shut down? If not you'll need a new keyboard. If is still wants to shutdown we'll need to look into the battery & temperature sensors within the system.