Update: I have solved the problem as follows.
1 I changed the name of the BT keyboard - I don't know if this relevant or not.
2 I took the keyboard out of range of my iMac by taking in down into my basement - when I did so and switched it on down there, the green light started to flash, indicating that it was now in pairing mode. Previously, when my keyboard was close to my iMac, the green light had not flashed.
3 I came back upstairs to my iMac, and BT setup recognised the keyboard under its new name.
4 BT setup then gave me the 8-digit pass code, which I entered, and the pairing was completed successfully.
So it seems that re-enabling the pairing mode can be achieved by taking the BT device out of range of the home computer, and once the BT device has established its pairing mode/status, the process works as it should. If this is correct, it may be of help to others with a similar problem.