Without actually seeing the Mac I can only give you my best guesses based on my experience.
Since the Mac seems to run ok while connected to the MagSafe adapter the MagSafe board (DC-in) and logic board are likely ok. To further test this I would try, if one is available, to run the Mac off of a fully charged battery.
With this in mind I would expect either the battery or battery connector board to be faulty. If the Mac runs off of a good/charged battery then it's likely just the battery. If it still doesn't run off of or charge the good charged battery then it's likely the battery connector board.
The top case (or upper case in iFixit terms) is the most likely component that would need to be replaced in order to fix the keyboard, since the keyboard is built into this component.
Hopefully that helps. The big grain of salt with all of this is that there could be damage at the logic board side of these connections. Unless there's physical corrosion visible then replacing the parts may be the only way to tell if this is the case.
Good luck!
crwdns2934105:0crwdne2934105:0
crwdns2934113:0crwdne2934113:0
crwdns2915270:0crwdne2915270:0
crwdns2889612:0crwdne2889612:0
0