Key signature notation is a relatively simple skill that can look hopelessly complicated. It is not that tough. It does require some thinking, and always wants a good deal of practice.
First you should know the principle behind key signatures. You will recall that in the key of F, for any song to sound right (on the piano, for example), every B in that song needs to be lowered ½ step, so that the note played is actually a B♭.
Listen to this familiar tune.
Which notes sound wrong? You can correct those notes by putting in a flat in front of each wrong note.
Now you can see that every occurrence of B must actually be a B♭ to make the song sound right to our ears.
We have written in the accidentals, but there is a shorter way of having those notes play correctly. It is the key signature. The key signature is simply a way of keeping the music uncluttered. Here is how the first example looks with a key signature.
Thus we have defined a key signature as a collection of sharps or flats, written just after the clef, which apply to the whole song.