I did not and still do not understand identifying a key when it differs from a scale.
As it's late and I need to get some sleep, in short and laymen-style:
A scale defines a group of notes used. That's basically all there is to it.
A key however defines (or rather follows - kinda like an egg/hen thing) a tonal center. The note/chord that makes you feel "home". The note that you can hum along and it'd just sound "inside".
Fwiw, a key doesn't even necessarily have to be major or minor. A tune in G might end on a Gmin chord at one time and on a Gmaj7 another time. In fact, that's not even an uncommon thing to create some "oh!" effect.
---
Another thing to possibly illustrate the difference between key and scale:
Let's say we're in the key of C major and the context is somewhat jazzy. We may play a typical II-V-I progression. Dm7, G7, Cmaj7.
Now, in that context, one *extremely* common practice would be to replace the V chord (I'll happily explain the whys and hows another time, for now you unfortunately just have to take my word for it) with a socalled tritone substitute, namely a Db7.
Now, that very chord is missing some very fundamental tones of the C major scale, namely the C and the E (root and major third of the tonic chord). And yet, we're not all of a sudden out of our C major key. In fact, due to its resolving nature, it actually *helps* to establish C as a tonal center.
Now, let's get to the scale aspect: If you were to improvise over that chord progression, the C major scale would not fit very well over that Db7 chord. So you'd have to use another combination of notes (likely "mixo #11", but we really do not need to get into that here). So, that's a completely different scale. And yet, instead of taking us away from C, it'll actually establish the key - all it'll do is to create a whole lot of tension which would then be nicely resolved into our C tonic chord, causing a pretty satisfying "yes, now we're home!" effect.
In a nutshell: While we're leaving the scale, we still stay within the key.
If you want, I could record that very progression and some hopefully plausible melodic lines on top to demonstrate the "we're sorta far away but still inside the key" effect. Not today anymore, though. Time for some sleep.