If you have the 2016 to 2019 model, then try cleaning the keyboard using the instructions in this Apple article (make sure to keep the can of compressed air upright or you may damage the laptop with the cold wet propellant):
How to clean the keyboard of your MacBook or MacBook Pro - Apple Support
See if your laptop qualifies for this free Apple Keyboard repair program:
https://support.apple.com/keyboard-service-program-for-mac-notebooks
FYI, here is the current list of the publicly acknowledged free repair programs for various Apple products (some products have multiple programs):
https://support.apple.com/service-programs