A ballcock (also balltap or fill valve) is a mechanism for filling water tanks, such as those found in flush toilets, while avoiding overflow. It was invented by Thomas Crapper.
It consists of a valve connected to a float by means of a lever, mounted near the top of the tank. The valve is connected to the incoming water supply, and is opened and closed by the lever which has the float mounted on the end. When the water level has risen to a preset fill line, the float forces the lever to close the valve and shut off the water flow.
When a toilet's handle is turned, a flapper valve is pulled upward by means or a rod or chain. It is designed to sink more slowly than the water, which will exit to the toilet bowl below, so that the tank may empty. As the tank water level drops, the float descends and actuates the fill valve. Water is fed to the tank to replenish its supply, and a smaller flow is directed into the overflow tube to refill the bowl.
Once the flapper valve closes, the water flow from the fill valve continues until the tank level again reaches the fill line. Should the float or valve fail and allow the water level to exceed the fill line, the water will pour into the overflow tube and out to the bowl.
These devices are sold at most hardware, plumbing supply, and home improvement stores.