We have seen that G is the fifth note (also called the fifth degree) of the C major scale. We have also seen that the G major scale uses the same notes as the C major scale, except for the second-to-last note. Instead of F, that note is F# – a half step higher. With that modification, the scale starting on G follows pattern of whose steps (s) and half steps (h) of a major scale: w-w-h-w-w-w-h.
We can repeat that pattern to find the key signatures of other keys. The fifth degree of the G major scale is D. The D major scale uses same as the notes as the G major scale, except for the second-to-last note. Instead of C, that note is C# – a half step higher. With that modification the scale starting on D follows the w-w-h-w-w-w-h pattern. So compared to G, the key of D has one more sharp in its key signature: C#. The key signature of D is two sharps, F# and C#.
The same pattern works for other scales:
G Major: 1 sharp
D Major: 2 sharps
A Major: 3 sharps
E Major: 4 sharps
B Major: 5 sharps
F# Major: 6 sharps
The key signatures are listed in order of the number of sharps. You can see that each key in the table adds one sharp on the seventh scale degree. For example, The key of E adds one sharp on the second line from the top in the treble clef – the line corresponding to D. This provides a quick and easy way to find the name of the corresponding major key. Take the last sharp, and go up one half step. If the last sharp is D#, then the key is E.
This rule gets a little tricky with the last entry in the list, the key of F# major. In this case, the last sharp is E#. E# is one half step higher than E. That note is normally called F, but to keep things consistent in terms of key signatures, it is called E#. (When a note has different names depending on the circumstances, these names are called enharmonic equivalents.) When the 7th scale degree (the last sharp) is E#, then the name of the key – the note a half step higher – is F#.