I get the exact same problem myself with my Microsoft Wedge Keyboard. It’s always disconnecting from my computer and can take up to 10 minutes to reconnect. When it does finally decide to reconnect it would more often than not start type non-stop a single letter (eg. wwwwwwwwwwwww). I notice this also happens when I plug in a USB stick into the computer, seems as if the USB stick is interfering with the the keyboard and/or bluetooth in some way. I also noticed when the device is “Paired” it doesn’t seem to work, it will only work when it says “Connected”.
I did upgrade my very old v2.1 Bluetooth USB dongle to a newer USB v4.1 dongle and that has made the device disconnect less, but it still happens a lot more than it should. I have also connected the same bluetooth keyboard (Microsoft Wedge Keyboard) on my Mac running MacOS to see how it would react, and the keyboard worked flawlessly for weeks, so surely it isn’t an issue with the keyboard.
I have tried pretty much everything that people have suggested in this feed, but nothing has worked. I did hear Windows 10 v2004 is improving the way in which you connect a device to bluetooth, at least makes it easy to connect, maybe Microsoft will behind the scenes fix this issue, least that is what I am hoping for.
I have found my Surface Bluetooth keyboard disconnects far less frequently since I installed the specific driver for my USB Bluetooth adapter. Before I installed it, the keyboard would disconnect many times a day. Now its once every couple of weeks.
Windows 10 will automatically install a driver for these devices - but the one from the manufacturer seems much better in this respect.
You'll need to identify the manufacturer of the bluetooth dongle (or chip if built-in) and visit their website support section. Download and install the driver (just like any other windows installer).
Worth a try. Probably a good idea to create a restore point before you do it though - that way you can roll-back if anything unexpected happens.