Thank you for posting your inquiry here in Microsoft Community, IB90.
We are sorry to hear about the keyboard disconnecting by it's own.
- Run Surface Diagnostic Toolkit and check Windows Update.
- Run the System File Checker.
- Force the device to shutdown and restart. Press the power button for 15 seconds.
- Install the drivers package. Check the specific OS build of your Windows Settings> System> About. Download the driver and firmware for Surface, choose Surface Book 2 and click download on the next page. Please choose the .msi file that matches your current OS Build and click Next. After the download, runand installthe .msi then Restart the Surface Device.
- Try to manually detached and re-attach the screen and see if the detaching issue will happen again.
- Uninstall the Unknown USB device (Port Reset Failed) and restart the device.
- Restart Surface DTX, Open Task Manager, go to Processes and select Surface DTX then click End Task.
- Refresh the driver. Uninstall and Reinstall Surface DTX in Device manager, In the search box on the taskbar, type device manager, and then select Device Manager from the list of results > In Device Manager, select System tab > Uninstall Surface DTX and restart your Surface.
Hope this helps, otherwise, let us know so we can further assist.