The key signature is the combination of either sharps (♯) or flats (♭) grouped together in the beginning of a music staff. It tells us what scale a piece is mainly made from, or centers around.
A composition may have many different scales or tonalities, but in so called tonal music; music with a tonal center (usually major or minor), the piece will gravitate to one specific note that will feel more like “home”.
This"home"note is also the note that the piece usually finishes with. It is called the root, which is the first note of the “key” or scale that the piece is mainly built with. The key signature tells us all this in the beginning of the staff.
To simplify note reading.
All the notes that are changed in the main scale used for a composition, have their sharps or flats written in the beginning of each staff instead of being written before every single note that is changed.
For example, an A major scale has three sharps. If a composition is using mainly this scale, and finishes with an A; it is in "A major". The signature you will see are three sharps in the beginning of the staff, telling us that in this piece all the F's, C's and G's need to be raised 1/2 step.
There might still be other sharps (♯), flats (♭) or naturals (♮) in the score. They are called “accidentals” and are only temporary. They last only for one measure and for that particular note. The sharps or flats in the key signature lasts for all the same notes in the whole piece.
There are 12 different notes in the western notation. On the piano keyboard you can see them easily; 7 white keys and 5 black. You can create a scale from every note.
But isn't there 15 major (and related minor) tonalities; 7 with sharps, 7 with flats and one with nothing?
In reality there are only 12 different ones... So how does this go together?
This is because some notes are “enharmonic”, meaning that they sound the same but have different names. For example F# major and Gb major are “enharmonic”, they look and sound exactly the same on the piano keyboard, but are written differently with notes.
The Circle of Fifths neatly displays all 15 major keys and makes it easy to see how many sharps or flats each scale/key/tonality has:
You can see that for example B major and Cb major have totally different signatures, but when played they sound exactly the same (enharmonic), since the exact same piano keys are used!
Each major scale shares the same key signature with a minor scale. That is called that they are “related”.
All major scales have one “relative” minor. They share the same notes, but have different starting notes- or roots.
For example C major and A minor are relative key signatures. The C major scale has no sharps or flats in the scale, so its "signature" is without any sharps or flats! Its relative A minor scale, shares the same notes and signature but starts from A.
The fastest way to drill key signatures is with flashcards. Here is a good set to practice with: Essentials of Music Theory Flashcards (Amazon)
To find the relative minor for each major key, you only have to go 3 half steps down from the major. You will also find it by starting a new scale on the sixth step of the major scale.
Minor scales have some alterations on the 6th and 7th steps, compared to the major scales that have no changes.
Basically, there is one minor scale, but with alternative 6th and 7th steps.
But, when you learn about music theory you will probably learn that there are three types of minor scales;
The changed 6th and 7th steps of a minor scale are never written in the key signature, but since they are temporary they are written as they are used in the score as accidentals. They may be both sharps, flats or even naturals.
The sharps and the flats are added one by one for each key in a “zig-zag” pattern.
But the sharps have one exception to that pattern when adding A. Since the A (on the treble staff) if following the pattern would be on a help line, (and that would really look messy to put a sharp on) that A sharp is moved down an octave. After that it continues as usual.
The order of the sharps: The sharps are added from F#, a fourth down, a fifth up etc. with the exception of A# as mentioned above.
The order of the sharps is: F-C-G-D-A-E-B.
The order of the flats: The flats are added from Bb, a fourth up, a fifth down etc. no exceptions. (Neat pattern!)
The order is: B-E-A-D-G-C-F
Hrrmm… See the pattern? If you need to memorize the order – it is backwards from the sharps!
OK. This was simply the order of the sharps and flats. Now how do you know for which scale or key each signature is? There are two tricks for this:
The only exception here is if you have only one flat, the first one on Bb. Since there is no flat before that- you simply have to memorize that this is the key signature for F major or its relative, D minor. The same goes for C major, since it has no sharps or flats- but you already knew that, didn't you!