Since your keyboard appears to work at boot here's what I suggest: (i) send your system into recovery mode from the GNU GRUB menu, (ii) drop to a root shell prompt, and finally, (iii) issue a command to reinstall / install input device drivers. This should help you gain keyboard and mouse access for accessing the Ubuntu desktop.
Let's start by booting into recovery mode.
Follow the below instructions which I've grabbed from the Ubuntu Wiki Recovery Mode page:
- Switch on your computer.
- Wait until the BIOS has finished loading, or has almost finished. (During this time you will probably see a logo of your computer manufacturer.)
- Quickly press and hold the Shift key, which will bring up the GNU GRUB menu. (If you see the Ubuntu logo, you've missed the point where you can enter the GRUB menu.)
- Select the line which starts with "Advanced options".
- Select the line ending with "(recovery mode)", probably the second line, something like:
Ubuntu GNU/Linux, with Linux 3.8.0-26-generic (recovery mode)
- Press Return and your machine will begin the boot process.
- After a few moments, your workstation should display a menu with a number of options. One of the options (you may need to scroll down to the bottom of the list) will be "Drop to root shell prompt". Press Return with this option highlighted.
You should now be at the root shell prompt.
There's a semi-related Ask Ubuntu question about the keyboard and mouse locking after suspend. I believe this question's accepted answer to reinstall or install input device drivers should help resolve the issue.
From the shell prompt type the following:
sudo apt-get install xserver-xorg-input-all
In case that doesn't work, try:
sudo apt-get install --reinstall xserver-xorg-input-all
Once the command completes, reboot your system:
sudo reboot now
If all went well you should now be able to access the Ubuntu desktop with your input devices.