Which Surface model is this?
What kind of keyboard stopped working?
Unplug or turn off the new mouse
Restart the Surface completely
After reboot, test the keyboard before reconnecting the mouse.
Detach and reattach the Type Cover firmly.
Go to Device Manager → Keyboards — check if there's a yellow warning icon
Right-click → Uninstall device, then reattach the Type Cover to reinstall.
If It's a Bluetooth Keyboard: Go to Settings → Bluetooth & devices → remove the keyboard, then re-pair it
Also check if the keyboard battery is low.
Go to Settings → Accessibility → Keyboard
Make sure Filter Keys and Sticky Keys are OFF Microsoft Reference Article: