I think velocity sensitivity (or touch sensitivity as some companies call it) is achieved by having at least two sensors, or else a sensor that can detect when a key passes at least two points or positions as it's being depressed. (Honestly, I don't really know the details of how it works.) The keyboard then takes the amount of time that elapsed between when the key passed point A and when it passed point B, and uses that time (or "velocity") to determine how loudly to play the note.
There are also some keyboards that use a "tri-sensor" approach, measuring the time from point A to point B, and then from point B to point C, which allows even greater nuances of control-- for instance, maybe the performer presses the key so lightly that it goes from point A to point B, but never reaches point C, or takes longer to go from point B to point C, etc., so the keyboard is able to detect these situations and play the note accordingly.