A ballcock works with a valve connected to a float by a lever. The valve is connected to the water supply. The float rises as water comes in; when the water reaches a predetermined level, the mechanism forces the lever to close the valve and stop the water flow.
Typical in flush toilets, the ballcock eliminates the risk of overflow and backflow by using negative feedback and proportional control. Repairing a broken ballcock in a toilet does not require previous plumbing knowledge.
The ballcock was invented in 1790 by José Antonio de Alzate y Ramírez, a Mexican priest and scientist.