I Got It Working
I had this exact same problem, was about to go and get a corded keyboard.
After some recent Windows 10 forced update the bluetooth keyboard stopped working
after I had to replace the batteries I could not pair it.
It kept asking for a PIN but no matter what I entered it would no longer pair.
It would not pair in the Control Panel / Bluetooth & other devices section and
did not give me an option to put in a code.
What worked finally for me what:
Start -> Run -> devicepairingwizard
Select your keyboard, click next
Click 'or enter a code' link below
On this screen a numeric code will be presented
Quickly type in the code you see on the Wireless Keyboard and press Enter
If successful it will install some files and pair!
I had to try a couple of times to input the code quick enough but thankfully it worked.
Hope this helps out others.