I did a bit of troubleshooting and found that the keyboard worked correctly in the BIOS and also worked fine in a Linux Live CD. I could even remote desktop onto the machine and it the keyboard worked correctly. I tried a few different keyboards and the computer did the same. So I thought it was a driver issue...
To fix it I tried to do a check disk (chkdsk /r) from the recovery console on Windows XP installation CD. This is done by running the Windows XP installation CD, choosing Repair Console (option 'r') from the first option screen and then typing 'chkdsk /r' when the console loads.
Check disk took about 1 - 2 hours to complete and showed that it had fixed some errors. So I exited the console and rebooted the machine however the problem remained.
Finally I found a post by Ryan. T. Adams called Keyboard Not Working Due to Missing Or Corrupt Drivers (Code 39). This had a step by step guide of how to fix the problem.
Below are the steps I followed to fix the problem. Please note this method requires editing the registery so make a backup of the registry and be careful.
- Go to your Start menu and click “Run…”
- In the Run box that opens, type “regedit” and press Enter.
- In the new window that opens, click the “Edit” menu, then “Find.”
- In the find filed, type “kbdclass” and press enter.
- The registry editor will now search for any key that has “kbdclass” in it. What you are looking for is any that have a name of “UpperFilters” and a data of ” something_random_here kbdclass” You may need to go to “Edit,” “Find Next” if the search finds something else first.
- Once you find the key, double click on it, and edit the text so that it includes only “kbdclass”. Press OK.
- Continue searching (using the “Edit” and “Find Next” menu) until you have found and edited all of the “UpperFilters” keys. Again, all should have a data filed that includes only “kbdclass”.
- Close the registry editor.
- Go to the device manager, find your keyboard in the list (which should still be reporting a “Code 39″ error), and uninstall it.
- You should then restart your computer, and with any luck, your keyboard will work upon rebooting.
Thanks to Ryan for this great fix