Chosen Solution

My MacBook Pro will not stay on unless the shift key is held down. If I release the key the MacBook shuts down. I reinstalled OSX (Yosemite) and still have the same problem. I also notice that the OS does not see the battery.

Sounds like your battery has swelled! You could give this gem of an app a try: coconutBattery it will tell you what the SMC services are reporting. Post a screen shot on what it tells you here. I would also check the MagSafe adapters cable is it damaged in any way? Often the point of the connector gets a bump or along the wire gets twisted or cut. All of these could cause the cable to short out which can harm your computer! If its damaged stop using it and get a new unit. Inspect the MagSafe connector ends (both) are they clean, do they look melted? If the battery has indeed swelled it will press on the keyboard from the back side causing both keyboard & trackpad problems. You’ll need to take the battery out and check if its good still. Update (06/07/2016) I forgot to post the steps to take the battery out. Here they are: MacBook Pro 13" Unibody Late 2011 Battery Replacement. Don’t forget to check the MagSafe connector on the system.