The biggest help for me understanding the sharps and flats in a key came from studying the circle of fifths, and the scales on a piano keyboard diagram.
If you visualize a scale as spaces between notes instead of the notes themselves, it makes a ton of sense.
There is a Ted-X video: Duncan R Lorien, the “Language of Music” that explains it very well. Watching that video and re-visiting scales was a big milestone for me.
Hope it helps. -Glade