A key signature is a set of flats and sharps at the start of a musical piece's notation. All the notes matching the sharps and flats will be sharpened and flattened accordingly for as long as the key signature is still in place until it is replaced with a new key signature. The key signature gives hint to which key the piece is in (not always the same). For example, this is the key signature of B flat:

https://en.wikipedia.org/wiki/B-flat_major#/media/File:B-flat-major_g-minor.svg

https://en.wikipedia.org/wiki/B-flat_major#/media/File:B-flat-major_g-minor.svg

But why does it have 2 flat symbols at the particular locations of B and E? And more applicably, how do we learn to remember and recognize key signatures quickly?

Construction

Let's start from the very beginning: the major diatonic scale, the underlying building block of most Western music. I'm just gonna talk about major scales for now. This scale has a series of notes, arranged so that the distances between consecutive notes follow a pattern of:

whole tone (W), whole tone, half tone (H), whole tone, whole tone, half tone

Start by writing down the natural note symbols:

B C D E F G A (B)

Then we adjust the series, pulling and pushing notes with the flat and sharp symbols, to fit the pattern above:

B♭  C   D   E♭  F   G   A  (B♭)
  W   W   H   W   W   W   H

Let's do this for all the notes, choosing C as the center:

lower     G♭ A♭ B♭ C♭ D♭ E♭ F     6 ♭'s
          G  A  B  C  D  E  F♯    1 ♯
          G♯ A♯ B♯ Cx Dx Ex Fx    _
          A♭ B♭ C  D♭ E♭ F  G     4 ♭'s
          A  B  C♯ D  E  F♯ G♯    3 ♯'s
          A♯ B♯ Cx D♯ E♯ Fx Gx    _
          B♭ C  D  E♭ F  G  A     2 ♭'s
          B  C♯ D♯ E  F♯ G♯ A♯    5 ♯'s
          C♭ D♭ E♭ F♭ G♭ A♭ B♭    7 ♭'s
center    C  D  E  F  G  A  B     0
          C♯ D♯ E♯ F♯ G♯ A♯ B♯    7 ♯'s
          D♭ E♭ F  G♭ A♭ B♭ C     5 ♭'s
          D  E  F♯ G  A  B  C♯    2 ♯'s
          D♯ E♯ Fx G♯ A♯ B♯ Cx    _
          E♭ F  G  A♭ B♭ C  D     3 ♭'s
          E  F♯ G♯ A  B  C♯ D♯    4 ♯'s
          F♭ G♭ A♭ B𝄫 C♭ D♭ E♭    _
          F  G  A  B♭ C  D  E     1 ♭
higher    F♯ G♯ A♯ B  C♯ D♯ E♯    6 ♯'s

<aside> 💡 Note the omission of B♯ and E♯ because they would just be the same as C and F, respectively. Also note that G♯, A♯, D♯ and F♭ require double flats (𝄫) and double sharps (𝄪, I used x in the chart because 𝄪 is not available in the monospace font used by Notion) and are commonly replaced with their enharmonic equivalents (same note but different names, for example G♯ and A♭) of A♭, B♭, E♭ and E. Therefore, they will not be considered further.

</aside>

We can see that there is an obvious symmetry here. Let's try ordering based on the number of flats and sharps and listing out all the flattened and sharpened notes in each scale:

♯ 7  C♯:  F♯ C♯ G♯ D♯ A♯ E♯ B♯
  6  F♯:  F♯ C♯ G♯ D♯ A♯ E♯
  5  B:   F♯ C♯ G♯ D♯ A♯
  4  E:   F♯ C♯ G♯ D♯
  3  A:   F♯ C♯ G♯
  2  D:   F♯ C♯
  1  G:   F♯
  
♮    C

♭ 1  F:   B♭
  2  B♭:  B♭ E♭
  3  E♭:  B♭ E♭ A♭
  4  A♭:  B♭ E♭ A♭ D♭
  5  D♭:  B♭ E♭ A♭ D♭ G♭
  6  G♭:  B♭ E♭ A♭ D♭ G♭ C♭
  7  C♭:  B♭ E♭ A♭ D♭ G♭ C♭ F♭

Noice! 😎

Notice that from C, as we go up, each note is a 5th apart:

C D E F G A B C D E F G A B C D E F G A B C D E F G A B C

And as we go down, each note is a 4th apart:

C D E F G A B C D E F G A B C D E F G A B C