This example demonstrates one octave of the major scale ascending and descending in every key. Play the whole exercise in the first position and then in all of the five forms along the fretboard until you can do it easily. Learning scales may not seem as interesting as playing melodies, but a little effort at this stage will pay off later on. Memorize the notes of each scale and then try playing it with your eyes closed, while visualizing how the notation for the scale would look. Once you know all the scales, you will be able to read music better, play melodies confidently in any key and you will be able to improvise in any key much more easily.
These exercises will help you get more comfortable playing in any key. Remember to play each one in all possible positions on the fretboard. Each one is written in a different key, but they are intended to be played in all keys. The first one is a sequence in the key of D major.
This one alternates between the note B and every other note in the B major scale, both ascending and descending.
Don't forget to practice the chromatic scale in every key. Here it is in the key of Gb
Finally, here is one which alternates between the note A and every other note in the A chromatic scale, once again ascending and descending.