Turn off your computer, unplug the plug, deal with the mess at hand before you go any further!
Electricity and liquids, for the most part, don't mix. I remember learning this important tidbit at a very early age, and it was reconfirmed in school, as teacher after teacher said not to have drinks around the computer. But if you are unlucky enough to spill your coffee, soda, or water onto your computer...well, you better act fast.
Coffee is probably a computer worst enemy, with it's sugary sweetness and heat, coffee would do the worst damage of all. If it gets into your keyboard, attempt to vacuum, blot with paper towels, and air-blow it out. Turn it over and try to shake out any liquid, if this fails, there is not much hope, better get on down to the store and pick yourself up a new one if you expect to be doing any typing any time soon. Plus any left over sugar will make your keys stick.
Try the same with either water or soda, if there is only a small amount of liquid, there is a chance of recovery. Try leaving your keyboard over an air vent to see if there is any way to dry any more liquid out. Of course, this will not work as well for laptop.
If you spill on a laptop, try to get as much liquid out with a vacuum and air-blow as possible. If you know your way around the inside of a computer, take either your laptop or tower apart and try to dry each piece with the vacuum and air-blow. If you don't want to chance taking it all apart, just unscrew one side and vacuum and blow the liquid out.
Of course, if you feel unqualified to preform such a task, it would be a good time to call up a friend who knows what they are doing, or check in the yellow pages for a computer repair shop.
When all said and done, liquids and electricity don't mix. Liquids can be used as a conductor for electricity, and if you touch the liquid or the computer you can get shocked. Remember to unplug and turn off any computer pieces before attempting to clean them up to reduce the risk of being shocked.
There are some items on the market for computers that are waterproof, such as keyboards and mice. You can get a plastic covering for your computer tower as well to protect. But, when all is said and done, using bottles with lids and cups that can be closed is probably your best bet around a computer.