Missing pairing code when adding bluetooth device

Sometimes when pairing a bluetooth device (like a keyboard), a popup will ask us to introduce a pin code, but it is not shown.
To display it, go to Registry Editor and delete the entry (folder) from the following location:

  
Computer\HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Bluetooth\ExceptionDB\Addrs

Then try adding the keyboard again.