When the issue occurs I would start by looking in 'Device Manager', you can access it with the mouse by right clicking the start button and select 'Device Manager'. I would expand out "Human Interface Devices', "Keyboard' and 'Universal Serial Bus controllers'. From these look for devices with yellow '!', red 'X' or devices with a small circle with a downward facing black arrow. The first two indicated a problem and the arrow indicates a disabled device.
Another place to look, also accessible from right click the start button is 'Event Viewer' the system log may contains logs about the keyboard.
Some potential problems
- Keyboard hardware failing (common)
- Problem with the usb port (uncommon)
- Problem with the root hub...