As suggested above, try using a different keyboard and see if the problem remains, or changes in any way. Sometimes the pins break-off in the PS/2 port, sometimes it's cable fatigue, sometimes the internals simply fail. If using a different keyboard suddenly works, trash the non-functional one. Be sure to be careful when trying another device, in case a pin might have broken off for whatever obscure reason.
If the problem persists, and your motherboard is clean, you might have a more serious problem. Usually if your keyboard is not detected as "present" upon boot-up, the system speaker will complain at you following a prompt of the lack of a keyboard. Double-check that the caps-lock/numlock/scroll-lock keys respond by the indicator on the keyboard. If not, the machine crashed or does not see the keyboard properly.
I use an IBM model KB-8923 (the clone of it is the NEC model KB-6923) keyboard, and I have not had any failures or compatibility issues for longer than I can remember, at least 7 years across 4 widely varied machines....Maybe you should get one of these bomb-proof classics?
Try using a standard 101-key keyboard as a test. You can likely find them dirt-cheap at a thrift shop that takes donations, or even when someone tosses a computer in the trash.
As a rule, I always have a backup monitor, keyboard, mouse, floppy and hard drive handy should I suffer a failure. This will get me back up and running should I lose such critical devices.
I wish you luck....