If you have a live CD, one which will boot without installing a fresh operating
system (such as Ubuntu)boot from the CD and see if the system responds more
normally to mouse and keyboard. If it does you have possibly got a data
corruption which could be due to a failing hard drive or an electricity supply
sisk.
If you do have a live CD save your data ASAP.
If the keyboard and mouse don't work normally with the live CD you might have an
incipient processor or motherboard problem.