A dirty, dirty, dirty keyboard can be cleaned thoroughly easily, it doesn’t necessarily have to be thrown away—you can reuse it! Here’s how.
Unplug the keyboard. Then disassemble it, usually that means taking out the screws in the back and ending up with one plastic board holding all the keys and the (more or less) fancy casing. If the cable can be detached, even better.
Now, take the key board and the casing and put it in a dishwasher. Put it in an upright position. Close the dishwasher and let it do its dirty work.
When the dishwasher is done, take both parts of the keyboard and put them in a dry place. Again, in an upright position. Usually leaning them against a closet works fine. Leave them there for one or two days so the remaining water can drip out or evaporate. The longer, the better. It’s better to be safe than sorry.
Once the parts are dry again, reassemble the keyboard and plug it in. Usually (see disclaimer below) you’ll have a clean and working keyboard now. Even all the board chow is gone! Splendid.
If it doesn’t work correctly, it’s probably not entirely dry yet. Just let it dry for another day or so and try again.
Disclaimer: I’ve followed this procedure two times by now. The first time with an Apple Keyboard. No disassembling necessary (or possible). Worked fine. Second time just last week with a no-brand ergonomic PC keyboard. Both times I was successful. Your mileage may vary, and I won’t take any responsibility.