The key of a song is based on the tonic.
You can tell what key a song is in by the number of sharps and flats on the staff.
Sharps | Flats | ||
---|---|---|---|
Key | Number of # | Key | Number of ♭ |
C | 0 | C | 0 |
G | 1 | F | 1 |
D | 2 | B♭ | 2 |
A | 3 | E♭ | 3 |
E | 4 | A♭ | 4 |
B | 5 | D♭ | 5 |
F# | 6 | G♭ | 6 |
C# | 7 | C♭ | 7 |
Circle of Fifths
From here