It is a complicated mechanism but, basically, here's how it works. A piano key is a long lever. Inside the piano, when you press on a key, the other end of the lever initiates two actions: 1) a damper (small felt pad that silences the string) is lifted from the string and 2) the hammer is set in motion. The hammer is not directly connected to the key, so at a certain point, it is carried forward by its own momentum, and bounces off of the string. This way, the hammer does not remain in contact with the string, which would act to dampen the vibration and silence the string. As long as you hold the key down, the damper is remains raised and the string can continue to vibrate. When you let go of the key, the damper re-contacts the string and silences it. A final detail: although the description above refers to a singular "string," only the lowest piano notes are played by single strings. In the treble range, there are three strings for each note (the hammer hits all three at once), and in the lower midrange, there are two strings for each note. The string vibrates between two fixed points: where it is stretched over the bridge and the opposite end of the string, where it is attached to the frame. The vibration results in a standing wave on the string. The fixed points of the string don't move (nodes), while other points on the string modes.
It is a complicated mechanism but, basically, here's how it works. A piano key is a long lever. Inside the piano, when you press on a key, the other end of the lever initiates two actions: 1) a damper (small felt pad that silences the string) is lifted from the string and 2) the hammer is set in motion. The hammer is not directly connected to the key, so at a certain point, it is carried forward by its own momentum, and bounces off of the string. This way, the hammer does not remain in contact with the string, which would act to dampen the vibration and silence the string. As long as you hold the key down, the damper is remains raised and the string can continue to vibrate. When you let go of the key, the damper re-contacts the string and silences it. A final detail: although the description above refers to a singular "string," only the lowest piano notes are played by single strings. In the treble range, there are three strings for each note (the hammer hits all three at once), and in the lower midrange, there are two strings for each note. The string vibrates between two fixed points: where it is stretched over the bridge and the opposite end of the string, where it is attached to the frame. The vibration results in a standing wave on the string. The fixed points of the string don't move (nodes), while other points on the string modes.