A key is a specific part of a musical instrument. The purpose and function of the part in question depends on the instrument.
On instruments equipped with tuning machines, violins and guitars, for example, a key is part of a tuning machine. It is a worm gear with a key shaped end used to turn a cog, which, in turn, is attached to a post which winds the string. The key is used to make pitch adjustments to a string.
On woodwind instruments such as a flute or saxophone, keys are finger operated levers used to open or close tone holes, thereby shortening or lengthening the resonating tube of the instrument. The keys on the keyboard of a pipe organ also open and close various valves, but the air flow is driven mechanically rather than lung powered, and the flow of air is directed through different pipes tuned for each note. The keys of an accordion direct the air flow from a manually operated bellows across various tuned vibrating reeds.
On other keyboard instruments, a key may be a lever which mechanically triggers a hammer to strike a group of strings, as on a piano, or an electric switch which energizes an audio oscillator as on an electronic organ or a synthesizer.