Hello,
This is usually a hardware issue with the keyboard. Underneath the keyboard, there is a circuit board with numerous signal tracks. Cracks in the tracks, dust or debris buildup, or corrosion can disrupt the signal flow.
To diagnose a keyboard problem, it's essential to test with the onscreen keyboard or a different keyboard via USB or Bluetooth. If the alternative keyboard works, it's certain that the issue is hardware-related.