I understand that an easy way to determine the 'key' of a piece of music is to either look at the last sharp within the key signature and add a half step (semitone), ...
Technically, when the sharp is added to the key signature it signifies that tone becomes the leading tone and so the half step above that will be the tonic... provided the mode is major.
How is that supposed to work if the mode is minor? Now you need a new rule of thumb that says the minor tonic will be a whole step below "the last sharp."
...or look at the second to last flat.
How does that work with a key signature of one flat? There is no second to last flat in that case.
That rule also give no consideration whether the mode is major or minor?
Technically, adding a flat to the key signature signifies that tone is the subdominant when the mode is major, and in the minor mode it will be the minor submediant.
This isn't how you read key signatures. You just check the count of sharps or flats. And to know the tonic, you usually just look at the first bar or final cadence. But the details of finding the tonic are really a separate issue.
The first huge flaw in that "easy way" is it makes no distinction about mode, major or minor. The second flaw is in an attempt to make it "easy" it glosses over the detail that you still need four "rules" to cover the basic cases of key signatures of either sharps or flats and either major or minor mode.
By the time you make that "easy way" actually work you've done just as much work as learning the key signatures.
The typical thing for teachers to do seems to be rote memorization, like what Neil Meyer suggests in his answer. I think it's better to learn them in context through actual playing. At the very least make scale practice the same time to memorize key signatures. Instead of scale practice you could use simple classical stuff, like Czerny's Recreations, or a hymnal, to find lots of material in keys of zero to three sharps or flats.
The other reason to not use rote learning for key signatures is because it's more of a system than random facts. You should try to understand key signatures in a systematic way. When key signatures get to five or more sharps or flats they become more difficult. But you should understand why they become difficult.
This is my break down of key signatures, getting more difficult moving left to right, adding more sharps or flats...

"Common key signatures" and "enharmonic region" are labels I made up. I don't think you will find a chart like this in a textbook.
Broadly speaking key signatures get complicated when there are five or more sharps and flats, and for the most part those keys are the ones where the sharps or flats also apply to the tonic, because those keys can be respelled to various enharmonic equivalents.
That enharmonic equivalency does not come up in key signatures of four or less sharps or flats. For example, the key C#
minor, the tonic does take a sharp, but there are only four sharps in the key signature. This key is pretty common. It also doesn't have a practical enharmonic equivalent. It's enharmonic equivalent would be Db
minor, a theoretical keys signature that uses a double flat!

Here is a visual arrangement of key signatures that lists all practical key signatures along with their enharmonic equivalents...

...theoretically the chart is infinite. You could keep expanding to the left and right forever moving in perfect fifths, but those theoretical keys will have double, triple, etc sharps/flats which is impractical. The practical key signatures use 7 or less sharps/flats. You could say the number of key signatures is infinite, but the ones that are practical is a tiny, finite slice of them.
You should notice the symmetry of that chart. You can apply a similar symmetry at the keyboard. Start on the piano key for F#Gb
and then move ascending/descending from in contrary motion in half steps. Each side of that F#/Gb
pivot will render keys to the left and right which are the same number of sharps/flats...
TONIC: ...Eb E F F#/Gb G Ab A ...
KEY SIG: ...3b 4# 1b 6#/6b 1# 4b 3#...
| | | | | |
| | |------------| | |
| | | |
| |----------------------| |
| |
|--------------------------------|
Even though the musical system of 7 letters, 12 chromatic tones, and the layout of black and white piano keys seems a bit of a muddle, there is a definitely symmetry to it all, if you view it from the right perspective. But, most textbooks and teachers don't present these symmetries.
I don't mean to throw too much theory at you. The main points are...
- learn the musical alphabet in perfect fifths ascending and descending
- understand relative major/minor and enharmonic equivalency
- learn common keys of 0-4 sharps/flats through simple performance exercises
- be aware of the enharmonic complications of keys with 5 or more sharps/flats
If you embrace the idea of playing in all keys as an essential musical skill, just combine key signature learning with scale practice. By the time you have learned to play all of your scales you will know all the key signatures. If you don't embrace this idea, you will probably be forever befuddled by key signatures.