Try launching keyboard tester and observe what keys is not working well.
if your laptop is under warranty, send in for repairs.
what you can try first is to detach the keyboard ribbon connector to the mainboard and use an eraser to rub on the ribbon contacts. try installing it back and see if it works, else you will need to get replacement.
Sadly nowadays keyboard are not as lasting as previously. I had service a number of laptops due to faulty keyboard.
Internal circuit somehow either worn out or corrosion, due to humidity and misc…
Some of the keyboard replacement module price are still acceptable. You can check at ebay and aliexpress for it.
Some may agreed e.g. new macbook pro, ultrabook, while keyboard is fused / glued into the laptop case, which is a pain to replace and almost impossible, either need to strip all parts to expose the keyboard out / get new keyboard assembly with the laptop base.