I had the same issue on my apple macbook air and it was driving me round the bend. The keyboard/trackpad would work until I got to the login screen and the caps lock key would go off so then I had to use an external keyboard. I saw another forum that said to replace the trackpad cable https://www.ebay.com.au/itm/323335150179
which I ordered on ebay and replace it and it now works. Yahoo.
This video also mentions the problem with the trackpad flex cable and that it fixes this issue.
https://www.youtube.com/watch?v=BGPsUTWGqqg