Detach the Type Cover. Inspect the magnetic connector pins on:
The Surface
The keyboard
Look for: Dust, Bent pins, Corrosion
Clean gently with:
Dry microfiber cloth
OR cotton bud with very little isopropyl alcohol
Then reattach firmly.
Shut down completely.
Press and hold Power button for 20 seconds.
Release.
Wait 10 seconds.
Start normally.
Download the official driver package for:
Surface Pro 8
Shut down
Hold Volume Up
Press Power
Release Power but keep holding Volume Up
You’ll enter BIOS/UEFI.
Now check:
Does the keyboard work there?
If it works, then → Windows driver issue.
If it doesn't then most likely hardware failure