Key Signatures
A key signature is the set of sharps or flats written at the start of the staff that says, once and for all, which notes are altered throughout a piece. It's just a shorthand for a scale: D major always needs F♯ and C♯, so rather than mark every one, we declare them up front. Click around the circle of fifths below to see each key, its signature on the staff, and the scale on the keys.
Each step clockwise around the circle adds one sharp; each step anticlockwise adds one flat. And every signature is shared by two keys - a major and its relative minor - because they use exactly the same notes.
C major
relative minor: A minor
No sharps or flats.
The order of sharps and flats
The accidentals always appear in the same order. Sharps come in the order F C G D A E B (each a fifth apart); flats come in the exact reverse, B E A D G C F. So a key with three sharps always has F♯, C♯ and G♯ - never some other three. The staff above places them in their fixed positions.
The enharmonic keys
At the bottom of the circle the keys overlap: B major (5 sharps) is the same sounding key as C♭ major (7 flats); F♯ and G♭ are the same; C♯ and D♭ are the same. They're enharmonic - identical on the keyboard, different on the page. We show the more common spelling on the wheel; the other is just as valid.
Why fifths?
Arranging the keys by fifths is not arbitrary. Move up a perfect fifth and the new key shares all but one note with the old one, gaining a single sharp; move down a fifth (which lands on the same note as moving up a fourth) and you gain a single flat instead. Stepping by fifths is the smoothest path through the keys, which is part of why so much harmony moves this way. Read the same circle anticlockwise and you have the circle of fourths - the very same wheel travelled in the other direction.
What's left for later
This page uses the treble clef only and draws just the signature, not the notes of the scale on the staff. Bass clef, full notation of the scale, and a "name the key from its signature" quiz are all natural next steps.