Use GNU Solfege to train your ears to recognize musical intervals and chord 'qualities' (major, minor etc). Practice finding out by ear and singing the root note of chords (a teacher would be handy here, to guide you). The chord-recognition bit (next para) is also important for this. After a month or so of regular practice of this stuff, you just need to use a reference note (instrument, or preferably from a tuner or tuning fork) and your ears to know the key. Foolproof, no need to see any tab/sheet/other guitarist's fretboard - you hear it and you know it.
And I'm afraid I don't know what you mean by 'keys and scales for a song'. There's usually one key, and when one knows the key, why would one need to know any scales? Maybe you meant chords? Again, the answer to that too is GNU Solfege with the MMA package (train your ears to recognize chords - the 'Harmonic Progressions' exercise in Solfege).
(An additional benefit of the first para training is you no longer need sheets/tabs to play - you can just hear and play. And improvising becomes way better, because you hear the lines in your head and you can play them as you want them - once perfected, it takes out all the crappy trial and error, there's just pure spontaneous expression.
An additional benefit of the second para training is you'll innately know exactly what'll go well with what chord the rest of the group is playing. You always know what can sound good over what chord - another important skill for improvisation.)
(Alternatively, use this for ear training, it's pretty good and web-based, although there's no chord progression training - http://www.iwasdoingallright.com/tools/ ... ning/main/
PS - Are you a guitarist?
edit - Ha, guessed right, a fellow guitarist ^^