In musical notation, a key signature is a set of sharp (♯), flat (♭), and rarely, natural (♮) symbols placed together on the staff. Key signatures are generally written immediately after the clef at the beginning of a line of musical notation, although they can appear in other parts of a score, notably after a double barline.
A key signature designates notes that are to be played higher or lower than the corresponding natural notes and applies through to the end of the piece or up to the next key signature. A sharp symbol on a line or space in the key signature raises the notes on that line or space one semitone above the natural, and a flat lowers such notes one semitone. Further, a symbol in the key signature affects all the notes of one letter: for instance, a sharp on the top line of the treble staff applies to Fs not only on that line, but also to Fs in the bottom space of the staff, and to any other Fs. This convention was not universal until the late Baroque and early Classical period, however; music published in the 1720s and 1730s, for example, uses key signatures showing sharps or flats on both octaves for notes which fall within the staff.An accidental is an exception to the key signature, applying only in the measure in which it appears.
Although a key signature may be written using any combination of sharp and flat symbols, the most common series of thirteen homogeneous key signatures—ranging from six flats to six sharps, with each successive flat or sharp placed on the note a perfect fifth below or above, respectively, the previous one—is assumed in much of this article. A piece scored using a single diatonic key signature and no accidentals contains notes of at most seven of the twelve pitch classes, which seven being determined by the particular key signature.
Each major and minor key has an associated key signature that sharpens or flattens the notes which are used in its scale. However, it is not uncommon for a piece to be written with a key signature that does not match its key, for example, in some Baroque pieces, or in transcriptions of traditional modal folk tunes.Later on, this use of a key signature that is theoretically incorrect for a piece as a whole or a self-contained section of a piece became less common (in contrast to brief passages within a piece, which, as they modulate from key to key often temporarily disagree with the key signature); but it can be found at least as late as one of Beethoven's very late piano sonatas. For example, in his Sonata No. 31 in A♭ major, Op. 110, the first appearance of the Arioso section in the final movement is notated throughout in six flats; but it both begins and ends in A♭ minor and has a significant modulation to C♭ major, and both these keys theoretically require seven flats in their key signature. (The second appearance later in the movement of this same section, a semitone lower, in G minor, uses the correct key signature of two flats.) View More On Wikipedia.org