This idea is simple — play each major scale along to the recording until you find the one that sounds the 'nicest'. Playing the scale for the key the piece is in should sound pleasant, and all the notes should sound as if they 'belong'; playing any other scale will probably sound varying levels of dissonant, or be unpleasant to hear.
For example: if a recording is in the key of C Major, it will (generally) stick to the notes of the C Major scale — C, D, E, F, G, A and B. Playing a D Major scale on top of this (notes D, E, F#, G, A, B, C#) will sound dissonant, as the F# and C# notes do not belong in the key the recording is in and will stick out as odd or unpleasant. Likewise, playing a B♭ Major scale (notes B♭, C, D, E♭, F, G, A) will sound unpleasant because the notes B♭ and E♭ do not belong in the key the recording is in. Scales with more non-matching notes will sound less and less pleasant — for example, F# Major only shares 2 out of 7 notes with the scale of C Major, whereas G Major shares 6 out of 7.
You can make this easier by limiting the game to only major keys and scales you are familiar with, and adding extra keys as you learn them.