Sorry for the bad news, but if you've been using your laptop for 5 years or more, the keyboard has lasted as long as can be expected. Unlike external keyboards, some of which are very durable and rugged, laptop keyboards a light weight, and as a result, don't last very long.
I have already replaced the keyboards on all my laptops that are over 5 years old.
But, if the keyboard is going bad, the only thing you can do is have it replaced, and unless you are experienced at doing laptop servicing, you would do better taking it to a laptop repair facility and having them do it.
***If my post helped, click the White thumbs-up symbol to say thanks***
***Please mark Accept As Solution if my post solved your problem***
I am a volunteer and I do not work for, nor represent, HP