The "Key" you are in refers to what note the Scale of that Key begins at (doh, ray, mi, etc). C is the easiest because you start at C and play every note natural, i.e. no sharps or flats, until you get to the next C and stop there or come back down the scale until you stop at C again (low doh to high doh and back. On the keyboard all the white notes, the black notes being sharps - # , or flats - b).
If you were to play in the key of G you will see that there is one sharp in there - F. So find G then move up (or down depending on where you start from) playing all the notes naturally (all the white notes on a keyboard) until you get to F which you do not play, instead you move one fret up (to the black note immediately to the right of the F on the keyboard) play this note instead and continue until you get to G.
As you are playing in the key of G all G notes get written as "G"s and (with sheet music) you have to remember that all notes written as F are played as F#; with the chords that accompany the key of G it's less confusing to have all Gs written and played naturally and F# to appear as F# instead of Gb.
This can be as complex or as simple as you want it to get, but to know more you will need to find out about KEYs their relative SCALEs and the Chords that fit with them.