Trackpad on MacBook Pro 8,2 (15'' early 2011) goes crazy on power Whenever I connect the AC power cord the trackpad behaves erratically. If I disconnect the computer sometimes returns to normal, sometimes not.  

Some background:


My computer is originally from the Americas.
I'm currently using it in Europe with a European charger.
It is running macOS Sierra.
I modified some trackpad configuration on my other partition that I use for  Ubuntu.
I already tried resetting NPRAM and SMC and nothing changed.
I repaired my disks using the Disk Utility, however I can't use the Recovery Partition.  The loading bar appears but doesn't go away.  (I have tried waiting over an hour.)
The charger was given to me from my employer and it appears to be original and it also appears to be ok (in fact it was still wrapped in plastic as it appeared to be brand new).
I don't have a way of testing it with other chargers and I don't exactly remember if it was happening before this charger. (It could have been).
- Currently in my battery menu there is a legend saying "Condition: Replace Soon". I just replaced the battery for a new one and still is not working.
Sometimes when this happens I run the following commands to recover my trackpad


sudo kextunload /System/Library/Extensions/AppleUSBMultitouch.kext to disable

sudo kextload /System/Library/Extensions/AppleUSBMultitouch.kext to enable

However sometimes a Kernel Panic error appears.
- The last thing I noticed is that somehow only when I use two finger gestures I "lose" the trackpad.
- A new discovery is that the keyboard also behaves erratically sometimes like ignoring key presses.

So that's basically my story. I don't really know what to do next, also I don't really have a way to replicate the problem. I just know that only happens when the charger is connected.  Of course my MacBook is old but is really powerful.

To conclude, I ran Apple Hardware Test (extended) and everything appears to be fine!
After much research, trial and error and thanks to others in this amazing community I've found out the reason behind my trackpad and keyboard failures. 

The reason is that my MacBook Pro was missing a Cable Bracket inside. Why was that bracket missing is because my MBP was candidate for the motherboard replacement program that Apple did for Early 2011 MacBook Pro related to the Video Card issue (more on this thread so I took it in Mexico City to an "authorised" distributor called iShop and I remember that was the last time I saw the part (as I reckon I changed the keyboard myself after a coffee indigestion).

So I hope my answer help any soul with the same problem!