Sometimes the keyboard on a Mac can fail and you don't have to go to a service center to fix it. You can use the detailed instructions and recommendations that I found on this site https://setapp.com/
. They also helped me solve many problems with the keyboard of my Mac. I hope that you will be able to solve your keyboard problems thanks to this site, it is very useful!