firstly, you must know what is key signature.
like C Major, D Major, E Major ....
C Major is the most basic.
The notes are C, D, E, F, G, A, B
Let's look at G Major
The notes are G, A, B, C, D, E, F#
See, the difference between C Major and G Major is the F# note.
If you play the song and find that there are not #(sharps) or b(flats), chances are that it is a C Major key.
If you pay the song and find that you have to play a F# instead of a F, chances are that it is a G Major key.
Do a search for key signature on the web to learn more about it.
* the above are rough rough mentioned. there are reason what the key might be otherwise :lol: