A three-second violation in basketball is a violation that is given to an offensive player who stays in the paint for longer than three seconds. It is also given to a defensive player who stays in the paint for longer than three seconds if they are not actively guarding an offensive player. A player's feet must completely leave the paint before they can re-enter, lifting feet into the air and jumping do not count as leaving the paint. The count resets when that player leaves the paint.
This is why players that are near the key are constantly moving around the court. It's something players must be constantly aware of, because a violation of this rule results in a loss of possession of the ball. This countdown lasts for as long as a player's team has possession of the ball until a shot attempt is made. Amongst other duties, a referee will watch the paint during gameplay and use his arm to count each second that a player occupies the paint. Once the three seconds are up, the referee will blow the whistle and bring his arm forward with 3 fingers showing to signal that there was a three-second violation.
Once players get the ball in the paint, they have to make a move toward the basket to temporarily wave off the three-second countdown. This means that any attempt to pass or gain better position against a defender counts against a player's three seconds unless they leave the paint.