This worked for a clients Logitech S510 keyboard after it would no longer connect.
With the dongle plugged in press and hold the left side Ctrl+Alt, and F12 keys, then release all three buttons. Now push the Connect button on your Wireless Receiver, then the connect button on your wireless keyboard. Now press Esc.
You might need to play a little with the timing of the buttons if it doesn’t work straight away.