Guitar players and musicians in general have to learn how to play by ear. I think people get confused sometimes about music. They think that music is about black dots on paper. It’s not. Music is what happens after the black dots are translated into sound.
Music is an aural language and part of the fun of playing is trying to figure out what another player is saying. My friends and I as kids used to sit in front of the t.v. and try to play along with the music that was on our favorite shows. I still do that as a form of entertainment.
If you would like to try it here is my approach. You have to know at least one major scale shape that is movable. Begin to play your major scale shape when the music on the t.v. starts to play. Move up or down a whole step if your first key doesn’t work. Continue this process until you find the right key. After you have done this a few times you will get much faster at finding the right key.