I am a quite happy user of Logitech Bluetooth keyboards. Sometimes I'm not so happy; I know the issue you have, it occurs every now and then. The most clear, easy to detect reasons have been a dropped or otherwise bad connection between the keyboard and Bluetooth receiver, outdated Bluetooth drivers or bad batteries.
I nowadays have this issue not too often. I replace the batteries quite often, not waiting SetPoint (Logitech's control app) to tell batteries are low, using rechargeable ones so that I always have for each keyboard one set batteries in keyboard, at least one fully charged waiting and one set in charger to be charged. I also check and update Bluetooth drivers regularly.
Kari