Changing key within your song is a great way to change the mood of certain sections, create interest or add and resolve tension. Plenty of great rock songs never change key - Smells Like Teen Spirit uses the exact same 4 chords throughout the entire song - and you shouldn't use it just because you can. Use it when it makes sense and you want to make part of your song stand out by making it darker, happier or more mysterious than other parts.
Here are two small examples transitioning from a verse to a chorus and back with a key change. Have a listen
Sounds like the same to you? Well, they are almost the same, but not quite. The chord just before the chorus is different in the two examples and I think that Transition 2 sounds more natural. But why? Let's have a look at what exactly is going on.
The verse is in E-minor and the chorus is in G-minor.
Verse (Transition 1): Em | D | Am | G | Em | C | Am | Am
Verse (Transition 2): Em | D | Am | G | Em | C | D | D
Chorus: Eb | F | Gm | Gm | Eb | Cm | D | D
Notice that even though I'm jumping from one minor scale to another minor scale, the chorus has a more positive feeling to it? That is because I'm entering it on a major chord - Eb major.
The reson the key change in Transition 2 works better (in my opinion) is because the last chord in the verse, the D major chord, is
The harmonic minor scale is a minor scale in which the seventh degree is pushed up by a semitone, which makes it a 'leading note' towards the tonic of the scale. This alteration to the natural minor scale causes the dominant chord to become a major chord, e.g. in G naturalminor, the dominant chord is D minor but in G harmonic minor, the dominant is D major!
Now because we end the verse on a D major chord, it leads up to the G (due to the F# note) and thus, we can easily transition into the G minor scale without it sounding unnatural. And since we are ending the chorus on D major, we can simply fall back into the verse because D major is a chord in that key
In Transition 1, we end the verse on an A minor chord, which is part of the E minor scale but is not part of the G minor scale (and not closely related either) and thus the key change sounds a bit more abrupt and sudden. Now a sudden change might be what you are after and is certainly appropriate in certain situations. Personally though, I prefer the harmonies to flow together a bit better, which is why I prefer the D major chord for the transition.
To smooth out the transition when changing keys, you should generally go through intermediate chords - chords which are either common or related to both your current and your new key.
For example, if you want to transition between A minor and D major, you can look at the chords in those scales
A minor: Am, Bdim, C, Dm, Em, F, G
D major: D, Em, F#m, G, Am, Bm, C#dim
Additionally, the major dominant for the A minor scale is D major (how convenient ;)) and for the D major scale it is A major.
Your best intermediate chords for a key shift would therefore be either common chords (Am, Em, G) or a dominant chord, e.g. using D major to transition to A minor.
To conclude this post, I have turned the Transition 2 example into a song fragment to demonstrate how the key change could sound in the context of a song.
Note that during the transition, the bass and the drums change and a new instrument (distorted guitar) is introduced - these are additional tools that can be used to 'glue' transitions together and I think even Transition 1 would have worked alright in this instance because the sudden key change isn't harsh enough to break the glue provided by all the other elements.
Here's the song fragment with Transition 1 - enjoy!
Changing key can introduce a lot of excitement into your songs, make use of them!