A key signature is a set of flats or sharps and is used to notify which notes that will be altered with flats or sharps. The key signature is always written just after the clefs of staves.
In the example above, the key signature indicates that all B, E and A notes will be altered in B♭, E♭ and A♭, because the three first flats in the flats order are B♭, E♭ and A♭.
It is exactly the same as this below:
The key signature may be null (no sharps or flats), or it can contain from one to seven flats, or from one to seven sharps, but a key signature can't be a mixture of sharps and flats.
Here are some examples of key signatures:
You can see that the flats and the sharps are written on specific lines or space of the staff (stave ): All sharps and flats of the key signature are written like the flats order and the sharps order
External links to learn more about:
1 - https://www.dolmetsch.com/musictheory9.htm
2 - https://musicterms.artopium.com/k/Keysignature.htm
All music practice games: Let's play to our free games