OP wrote:
"how much would it cost to replace the keyboard?
or can i buy one from ebay and fix it myself?"
The keyboard IS NOT "replaceable" (as a separate part).
The ENTIRE TOP CASE of the computer must be "replaced".
That's why these laptops are "time bombs".
You cannot repair this on your own, for cheap.
Further, the Apple extended warranty on the keyboard has run out on you (4 years from date of purchase).
Your options now are limited:
- Pay to have the repair done (which involves an entire new top case) -- figure $800-900.
- Rather than pay that, start looking for a replacement.
We don't know "where in the world" you are, but in the USA the 2021 MacBook Pro models can now be found "on sale" for up to $400 off list price.
I'd take the [projected] cost of repairs, add some more money, and just replace what you have now.
You might be able to sell the old one "for parts"...