Unfortunately, it may be a hardware issue.
I read on
https://www.androidauthority.com/blackberry-key2-problems-and-how-to-fix-them-898296/
"Some issues with the keyboard are known bugs and BlackBerry is working to fix them. For a lot of the other issues, particularly where buttons stop working, your only option is to pick up a replacement. There appears to have been a quality control issue at some point as quite a few people are facing these issues."
I was thinking of just replacing the keyboard since everything else works: fingerprint, lights up, scrolling up and down but not the physical buttons.