In order to indicate the black keys, which are the notes “in between” the white keys, we use symbols in front of the notes we want to alter. The symbol to play a note higher (or musically one half-step / semitone higher) in pitch and thus one key to the right is called a sharp and looks like the number symbol #. The symbol to play one note lower (or musically one half-step / semitone lower) is called a flat and looks like a lower case letter b. We put these symbols in directly in front of the notes we want to make sharp or flat. After making a note sharp or flat if we want to play it in its original unaltered position again later in the same measure (or piece) we use another symbol called a natural sign, which looks like a little slanted rectangle with some extended lines. This effectively “cancels out” the previous sharp or flat sign.
This also means that any given black key (or white key depending upon how the music is written and in what key signature) can be labeled as a sharp or flat. This ability to identify one key as sharp or flat is called enharmonic naming. The determining factor in which a symbol is used is whether or not the key signature of the song uses sharps or flats. The idea is to maintain consistency with visual and conceptual clarity. This is done to make the musical alphabet letters in any given musical piece as easy as possible to read. So in the key of G major for example, we use the letters: G, A, B, C, D, E and F-sharp. We do not use: G, A, B, C, D, E and G-flat. This is because the first does not duplicate letters and thus is easier to see and quickly grasp.