The foundation of music lies within key signatures. A key is simply a group of notes in which a scale or chord(s) is derived from. A song will generally follow one or more key signatures. (Some may argue that there can be exceptions to this, for instance where a song will contain all 12 notes of the octave, but even then the song is derived from the chromatic scale. Others may argue that a song can follow a scale that doesn't exist, but this implies that no group of notes (scale) can be named, which is patently untrue.)
To find the key signature of a particular major or natural minor scale, one could use the "circle of fifths". The circle of fifths is a mnemonic device that allows the user to easily remember key signatures.
Using the circle of fifths, or just memorizing key signatures, one can ascertain how many sharps or flats exist within a particular key. One can also, use the circle to tell which notes are sharped of flatted. This knowledge can then be used to construct a scale in which all of the leads/melodies and chords in that particular key, are derived from.
An example; using the circle of fifths to find that the D major scale has 2 sharps, F# and C#, one could construct the D major scale using the following rules:
Using these rules, one could start to find the notes of the D major scale by first, writing all of the letters of the musical alphabet (obviously starting from D) out as follows:
Next, simply place a sharp next to the F and C:
With the above rules in mind, it is helpful to remember that when, for instance, the G major has an F# in it, the presence of the F# not only indicates which note is played, (the F#) it also implies (because of rule #2) that the F natural is NOT to be played. Therefore, think of each diatonic scale as containing all of the letter names, with certain letters, or notes sharped/flatted (raised or lowered a half-step).
* See the scales section for more information.
A song can change keys of course. There are two ways that you might see a key change. A song might permanently change keys. Usually a song that does this changes keys up to a key that is either a half or whole step above the original key. However, I've also seen (and wrote) music that might change keys in intervals of minor thirds or even perfect fifths. If you're a songwriter, use your creativity! I'm calling this a permanent key change, however the song may change keys from verse to chorus, modulating up a whole step going to the verse, and then back down to the original key when going back to another verse. The second type of key change is what is called a temporary modulation. In this case, the song might have one chord or two chords that don't fit in it's key signature. In the numbers section, I demonstrate how Amazing Grace does this.
It is possible for a song (or at least a series of chord progressions) to be in an ambiguous or implied key. For instance, both the keys of C major and F major, contain C and F major chords. (How do I know this? Because I know the number system. Check it out if I'm losing you.) If a song, or passage in a song, only repeats these two chords, the song could theoretically be in either key. But please note, that even though the instruments in the band might only be playing these two chords, if the singer was to sing a B natural, since B natural is not in the key of F major, the singer is removing the ambiguity and determining that the key of the song is in C major. As a lead player, you can also remove this ambiguity. In fact, if you were playing a solo over an ambiguous chord progression, you could go back and forth between both keys just by changing scales during your lead.
Now that you have a better understanding of key signatures, you might be wondering how you will benefit by knowing that a song is in the key of A major. There are at least two primary benefits to knowing the key signature of a song. Number one is by knowing the key signature, you will know which set of chords will work within the key. See the numbers section for details. Secondly, you'll know which scale(s) you can play for your leads. See the scales section for details.