Here is a source for the 'static buildup' bit.
https://superuser.com/questions/605559/pc-cleaning-why-is-vacuuming-a-static-electricity-risk-to-internal-components-bI don't know if this applies to keyboards, but I suppose it is possible, but I assume it wouldn't be very likely.
I want to add to this that the logic is sound, however, poorly explained from any specific source. The issue is that a vaccuum pulls in dust, and this dust rubs on the plastic and produces static on the plastic. Since plastic is a poor electrical conductor, it will not want to discharge into the person holding it, but contacting the electronics directly could actually discharge it. This is a common thing with plastic foams as well. We all know how styrofoam likes to cling to everything, which is the static build up that causes it. When you have plastic charged with electricity, and a 'ground' that is a distance from the plastic, you have a capacitor, and if the voltage on any point reaches high enough to overcome the spark gap, it will spark, straight through anything in the way.
This does not happen with compressed air because the air leaving the can is clean, there is no dust to generate static.
It is known as a fact that vaccuum cleaners accumulate static build up on the plastic attachments, but I have a hard time finding proof of this static build up actually doing damage. So I think people do exaggerate the risks here.
Either way, if you own an antique vaccuum with metal attachments, then you would have absolutely nothing to worry about.