Most keycaps, and other keyboard parts, are made from injection-moulding thermoplastic. The process of injection moulding involves melting the plastic using heat and injecting it under pressure into a steel mould where it sets. Depending on the plastic, the key will shrink more or less while it cools after demoulding.
Most keyboards in the world have keycaps made of ABS. ABS is short for "Acrylonitrile Butadiene Styrene", being a copolymer of these three monomers. ABS exists in many different formulations for different applications. (Poly)styrene is the main ingredient. Butadiene makes it more flexible and less brittle. Acrylonitrile makes it harder. ABS, and other blends with Polystyrene (PS) are some of the most commonly used plastics for computer equipment, including keyboard cases.
ABS keys is the prefered plastic to double-shot molding. That is because most other plastics shrink too much in the moulding process. Legends on ABS keys can also be pad-printed, laser-etched (burned) or laser-engraved (with or without infill). Because of the low shrinkage, some keyboards have space bars made of ABS even if other keys are made of PBT or POM.
ABS (and other polystyrene blends) will gradually turn yellow over time when subjected to ultraviolet light, a component of sunlight.
Yellowing occurs faster if the plastic contains flame-retardant chemicals, but it is more often used in the plastic of keyboard cases than in keys. You can sometimes find vintage keyboards where the case is very yellow, the space bar is less yellow and the other keys (made of PBT instead of ABS) have not yellowed at all.
Yellowing can be reversed with the Retr0bright process.
PBT (short for "polybutylene terephthalate") is one of the hardest, most durable materials for keycaps. It is more resilient against heat and chemicals than ABS, but its properties also makes it more difficult to mould, which makes it more uncommon.
Legends on PBT keys are often laser-etched or dye-sublimated but only very rarely double shot moulded. Because of shrinkage during demoulding, PBT is also rarely used for the largest key, the space bar, with a notable exception being Cherry.
PBT does not turn yellow from exposure to ultraviolet light, like ABS does. The resilience against heat makes it a good candidate for dyeing in a hot dye bath.
Polycarbonate (PC) is used mostly for key caps that are clear and transparent. PC does not yellow like polystyrene/ABS and is more impact-resistant than acrylic (PMMA). It is sometimes blended into ABS to make ABS-PC.
Coloured, transparent key caps made from PC have been made by Signature Plastics.
POM (short for "Polyoxymethylene") is a thermoplastic. It is sometimes called "(poly)acetal". A common brand name is "Delrin" (not to be confused with the keycap manufacturer "Devlin"). It is hard and durable but has low friction, being slippery to the touch. It tends to have a more muted downstroke, as it's much less dense than PBT and ABS keycaps.
Legends on POM keys are usually laser-engraved, with or without infill.
PVC (short for "polyvinyl chloride") is a relatively hard, middle-of-the-road plastic used in keycaps. Production of PVC is somewhat environmentally unfriendly and it is therefore not manufactured in some parts of the world.
It is probably the second most common keycap material, after ABS, widely used by Logitech, Dell, HP, and other mass market brands. PVC has average hardness and friction, but is sensitive to high heat, which will warp it.
PVC legends are often pad printed or stickers, due to its wide use in the mass market, though laser printing with infill can also be observed.
Because of the different density of the plastics in comparison to water (specific gravity), PBT caps will usually sink faster to the bottom than ABS caps.
There are some catches with this method. Trapped air bubbles will affect the net density. Because ABS is an alloy that can be blended with different ratios, not all ABS caps have the exact same plastic. If the legends are engraved and filled, the filling material could have a higher density than ABS.
You can test whether a key is ABS by subjecting it (preferably an area inside the key that can not be seen) to a q-tip dipped in acetone; If the plastic smears then it is probably ABS and definitely not PBT or POM.
Yield strength test
Different plastics have different strength and elasticity, so it is possible to exert pressure on a keycap and see how much it deforms or tears.
The image on the right shows an extreme case where the keycap is smashed to bits. This particular test might not always be representative, as it can be influenced by the keycap's construction (i.e. the thickness of the material and internal lattices).