I think it matters if the coffee had cream in it or not, which would make it more conductive. As rdklincorporated says, it's important to dry it completely; you should not have turned it on so soon, as you correctly noted.
I had a friend who dumped an entire glass of water into their keyboard. They removed the power and battery and set the computer on a scientific scale and kept it there till the weight didn't change any more; it took about two weeks (they live in Reno, where it's pretty dry.) The computer is still working fine a year later.
I collect the little silica gel packs that come in things you buy. Someday they may come in handy to help dry a soaked cell phone or other device. I've heard dry rice works also, but you don't want to pour rice in your MacBook! I took a wet Blackberry and wrapped it in a paper towel and covered it in rice for a couple weeks once; it would turn on after that, and talk to me, but it didn't recover to the point of usability.
Make it a rule to never set or hold a container of liquid where it can spill onto your keyboard.