How Keys Work

In Western music, C major is the natural major scale. This means that the half-steps naturally occur between E and F, and B and C.

For example: C D E^F G A B^C.

Note that E and F are the 3rd and 4th, and B and C are the 7th and root. This follows our major scale formula, where half-steps are between the 3rd and 4th and 7th and root. If you look on a piano, the naturally occurring half-steps (where there is no black key) are between E and F, and B and C.

But what if, for example, we want to play in the key of F? Without changing any notes, if we start and end on F, we get this pattern:

F G A B^C D E^F

Without changing any notes, our half-steps fall between 4 and 5 and 7 and 1. But we want them between 3 and 4, and 7 and 1. So, we flat the 4th note (the B) to get:

F G A^Bb C D E^F

Now our half-steps fall between 3 and 4, and 7 and 1. So we can say that, in the key of F major, we have one flat, Bb. The same happens with keys involving sharps. Let’s look at the key of D major:

D E^F G A B^C D

Without changing any notes, the half-steps fall between 2 and 3 and 6 and 7. But again, we want them between 3 and 4, and 7 and 1. So we raise the 3rd and 7th notes:

D E F#^G A B C#^D

Now our half-steps fall between 3 and 4, and 7 and 1, which is what we want. We had to sharp both F and C and so we can say the key of D major has two sharps, F# and C#.

This is the idea behind “keys.” We have to change the quality of some notes by lowering them a half-step (flatting them) or raising them a half-step (sharping them) in order to make them fit the major scale formula.

TL;DR: The naturally occurring half-steps in Western music are between E and F, and B and C. To make keys other than C major fit the major scale formula, we have to alter certain notes by either flatting or sharping them.