The lower-end musical keyboards usually are just based on rubber domes (just like the cheap computer keyboards are).
Most often, there are two domes (switches) per key, with a certain spacing along the key's axis, to detect velocity (but this is really all there is to it, the rest is similar to a computer keyboard). And each key is just using one or two springs for its action. Just like NKRO keyboards, multiplexed keyboards require a diode per key, which is the simplest topology overall. But even on cheap-ass musical keyboards, the diodes are really the least of your concern cost-wise, as most of the cost will come from the mechanical parts.
Good piano-like keyboards are a lot more sophisticated as tooki mentioned. They can also detect other parameters than just velocity.