Try cleaning the keyboard using the instructions in this Apple article, just make sure to keep the can of compressed air completely upright or you will damage the laptop with cold wet propellant:
How to clean the keyboard of your MacBook or MacBook Pro - Apple Support
If cleaning the keyboard does not help, then you have encountered the dreaded design & manufacturing defects of the Butterfly mechanism used in the 2016 to 2019 laptops. While Apple had a free repair program available, it is now expired for most people since it is only valid for up to four years after purchase.
Tip: Check the condition of the battery. If the battery condition is shown as "Service Recommended", then you can have Apple replace the battery for a lower cost than it would cost to have the keyboard repaired.....the same exact part will be used in the battery repair since the battery is glued to the underside of the Top Case Assembly of which the keyboard is an integrated part. I wouldn't mention the key issue since some techs may focus on that & want to charge for the more expensive repair.