Restart your Surface: Try restarting your Surface and see if the keyboard starts working again.
Check the connections: Make sure that the keyboard is securely attached to the Surface. If it’s a detachable keyboard, detach and reattach it to ensure that it’s properly connected.
Clean the connections: Use a soft cloth or an eraser to gently clean the connectors on the keyboard and the Surface. This can help remove any dirt or debris that may be interfering with the connection.
Update your Surface: Make sure that your Surface is up-to-date with the latest software updates. Go to Settings > Update & Security > Windows Update and check for any available updates.
Check the keyboard battery: If you’re using a wireless keyboard, make sure that the battery is charged and inserted properly.
Try another keyboard: If possible, try using another keyboard with your Surface to see if the problem is with the keyboard or the Surface itself.
Reset your Surface: If none of the above steps work, try resetting your Surface to its default settings. Go to Settings > Update & Security > Recovery > Reset this PC and follow the instructions. (Do take note that all data will and software installed will be wipe out, do remember to backup before resetting your pc)
If the keyboard still doesn’t work after trying all of these steps, it may be a hardware issue and you should contact Microsoft support or send your surface pro to Esmond Service Centre for Hardware repair.