Apple has identified no cause for the problems they call "behavior," but it's thought to be caused by dust and other particles that stick in the butterfly switch mechanism under keycaps.
Apple repaired affected keyboards for free, replacing one or more keys or the entire keyboard. The MacBook Pro are second-generation keyboards ̵
Then, last week, Apple surprised us with new 2018 MacBook Pro models featuring an improved third-generation keyboard for quieter typing. These models are not suitable for Apple's service program, at least not now.
Apple has not directly confirmed that the quieter third-generation keyboards solve the keyboard problems, but iFixit discovered that the MacBook Pro 2018 has a thin silicon barrier under each key to prevent dust and dirt from getting stuck.
For this reason, some customers hoped that Apple would outsource the second generation keyboards with third-generation keyboards as part of its service program, but MacRumor has learned that this is not the plan.
Asked if Apple Stores and Apple Authorized Service Providers could replace the second generation MacBook Pro 2016 and 2017 keyboards with the new third generation keyboards, Apple said, no, the third generation keyboard is exclusive to the 2018 MacBook Pro.
Hopefully, in this case, that means Apple has quietly tweaked the second-generation keyboard to be more reliable. It would not make much sense, and Apple would not like it much, because they continue to use spare keyboards that are just as broken as the ones they replace.
Of course, some customers who submit their MacBook Pro 2016 or 2017 may, in rare cases, receive a third generation keyboard left to the Apple Store and Apple Authorized Service Providers.
To initiate a repair, go to the Apple Support Portal, select Mac → Mac Notebooks → Hardware Issues → Keyboard Does Not Work As Expected → Get in for repair and make an appointment with an Apple Store or Apple Authorized Service Provider. Remember to back up your Mac before any maintenance.