I have used this technique to clean a dozen keyboards over the years, including several from my work that were "dingy" and needed a "facelift". The first time I heard of it was from an EE who said the method was fairly similar to the rinse baths used to clean circuit boards (remember, this was two decades ago). The detergent you use does a fairly nice job of scouring the plastics, and minimizes any corrosion (which is how your flatware doesn't turn into rust). Try to use straight granular detergent, and not a gel-pack or pillow-pack, as newer "tabs" can introduce other chemical agents that are less desirable. If you are concerned about electrical contacts, first try without any detergent at all.
Candidates
The trick to doing this is to look at the "style" and "type" of keyboard in use. As keyboards have become more sophisticated, there's more elements that can potentially have trouble. Old keyboards tend to be fairly mechanical beasts, with lots of contact switches and metal or plastic springs. These are the best candidates for a wash. Some keyboards, however, are not suitable for this - they either have parts that will not survive a wash intact (leatherette palm rests on a Microsoft Ergonomic 4000) or have embedded electronics that can trap water (LCD displays recessed behind a panel on gaming keyboards). In each case, look at the construction of the keyboard before proceeding, and keep in mind that it may not survive intact. If you're still willing, read on.
The Wash
The easiest way to do this is to place the keyboard in the top tray, key-side-down, so that the water/detergent mix will "spray up" into the keys themselves. This also helps a bit with drainage when you finally remove the keyboard. Also important is that you disable any "heated-dry cycle" that the dishwasher may have, as some have heating elements in the top and may cause damage or melted plastic. If this is not possible, consider placing it in the middle of the bottom rack, in such a way that the keyboard is away from any heating elements, and preferably suspended slightly higher than the base of the bottom rack (maybe perched on something else).
The Dry
Once the wash cycle has completed, remove the keyboard and place it on a towel in such a way that it is on-edge and tilted key-side-down, so that any residual water can work its way down through gravity. Let the keyboard remain in this position for a minimum of two days. After two days, pick the keyboard up and examine it - if you see any residual water all, let it sit for another two days, and so on. The point of this is to ensure that the keyboard will air-dry completely. If you have any doubts or concerns at all, leave the keyboard like this for a week to ensure that it has throughly air-dried.
The Test
Of course, the final test is to see if the keyboard works. Unfortunately, this means plugging it in. If at all possible, see if you can use an older (disposable?) machine to accomplish this. Although most machines will not be harmed by this, better safe than sorry. After you plug it in, be sure to test every key switch on the keyboard by stroking each row of keys with your finger. A text editor is a quick, easy way to check this.
Example
I once purchased (a long time ago) an NCD X terminal. The terminal had a fairly standard-looking keyboard, but it had one problem - someone appeared to have split 7up on several of the keys, making them stick and slide slowly (the E wouldn't move at all if I recall). After using the wash'n'dry method, I was able to get all but the E key to move freely. The E key "crunched" (the sugar had re-crystallized) but still was sticky. A second wash later it moved freely, and it never malfunctioned afterwards.
I'm not sure why you accepted an answer that just says 'It didn't work on this 1 keyboard I tried', rather than a far better one that says 'Depending on situation, it might work, and here are some things to think about and a guide to doing it carefully'. And judging by votes, others agree with me. – underscore_d – 2016-07-30T09:37:03.870
1@underscore_d: Because I too tried it and it failed. I'm sure it works sometimes, but I wouldn't recommend it. If you have a high-end keyboard, take it apart if you want to clean it. If you have a low-end keyboard, buy a new one if you don't like how dirty it is. And remember, on SE sites, "Accepting an answer is not meant to be a definitive and final statement indicating that the question has now been answered perfectly. It simply means that the author received an answer that worked for him or her personally." – raven – 2016-07-30T16:52:05.150
@raven Sorry, I somehow missed your comment saying it had failed for you too, maybe because it was 3 years later ;), so that makes sense now. I agree anyway that if the keyboard matters at all, it's better to use a more sophisticated method. But if they're budget ones and I have multiple to clean, I'll continue to take the risk :D – underscore_d – 2016-07-30T17:13:29.793
4I once spilled strawberry jam on a 5.25" floppy disk, right onto the magnetic medium. I carefully slit open the case, took out the disc inside and washed it gently with warm water and soap. I dried it and slit open a blank floppy and put the washed disc inside it. I got all my data off with no errors. – ErikE – 2011-05-05T17:33:43.207