In music theory, the key of a piece is the group of pitches, or scale, that forms the basis of a music composition in classical, Western art, and Western pop music.
The group features a tonic note and its corresponding chords, also called a tonic or tonic chord, which provides a subjective sense of arrival and rest, and also has a unique relationship to the other pitches of the same group, their corresponding chords, and pitches and chords outside the group. Notes and chords other than the tonic in a piece create varying degrees of tension, resolved when the tonic note or chord returns.
The key may be in the major or minor mode, though musicians assume major when this is not specified, e.g., "This piece is in C" implies that the key of the song is C major. Popular songs are usually in a key, and so is classical music during the common practice period, around 1650–1900. Longer pieces in the classical repertoire may have sections in contrasting keys.
Methods that establish the key for a particular piece can be complicated to explain and vary over music history. However, the chords most often used in a piece in a particular key are those that contain the notes in the corresponding scale, and conventional progressions of these chords, particularly cadences, orient the listener around the tonic.
The key signature is not always a reliable guide to the key of a written piece. It does not discriminate between a major key and its relative minor; the piece may modulate to a different key; if the modulation is brief, it may not involve a change of key signature, being indicated instead with accidentals. Occasionally, a piece in a mode such as Mixolydian or Dorian is written with a major or minor key signature appropriate to the tonic, and accidentals throughout the piece.
Pieces in modes not corresponding to major or minor keys may sometimes be referred to as being in the key of the tonic. A piece using some other type of harmony, resolving e.g. to A, might be described as "in A" to indicate that A is the tonal center of the piece.
An instrument is "in a key", an unrelated usage that means the pitches considered "natural" for that instrument. For example, modern trumpets are usually in the key of B♭, since the notes produced without using the valves correspond to the harmonic series whose fundamental pitch is B♭. (Such instruments are called transposing when their written notes differ from concert pitch.)
A key relationship is the relationship between keys, measured by common tone and nearness on the circle of fifths. See closely related key.
The key usually identifies the tonic note and/or chord: the note and/or major or minor triad that represents the final point of rest for a piece, or the focal point of a section. Though the key of a piece may be named in the title (e.g., Symphony in C major), or inferred from the key signature, the establishment of key is brought about via functional harmony, a sequence of chords leading to one or more cadences, and/or melodic motion (such as movement from the leading-tone to the tonic). For example, the key of G includes the following pitches: G, A, B, C, D, E, and F♯; and its corresponding tonic chord is G—B—D. Most often at the beginning and end of traditional pieces during the common practice period, the tonic, sometimes with its corresponding tonic chord, begins and ends a piece in a designated key. A key may be major or minor. Music can be described as being in the Dorian mode, or Phrygian, etc., and is thus usually thought of as in a specific mode rather than a key. Languages other than English may use other key naming systems.
People sometimes confuse key with scale. A scale is an ordered set of notes typically used in a key, while the key is the "center of gravity" established by particular chord progressions.
Cadences are particularly important in the establishment of key. Even cadences that do not include the tonic note or triad, such as half cadences and deceptive cadences, serve to establish key because those chord sequences imply a unique diatonic context.
Short pieces may stay in a single key throughout. A typical pattern for a simple song might be as follows: a phrase ends with a cadence on the tonic, a second phrase ends with a half cadence, then a final, longer, phrase ends with an authentic cadence on the tonic.
More elaborate pieces may establish the main key, then modulate to another key, or a series of keys, then back to the original key. In the Baroque it was common to repeat an entire phrase of music, called a ritornello, in each key once it was established. In Classical sonata form, the second key was typically marked with a contrasting theme. Another key may be treated as a temporary tonic, called tonicization.
In common practice period compositions, and most of the Western popular music of the 20th century, pieces always begin and end in the same key, even if (as in some Romantic-era music) the key is deliberately left ambiguous at first. Some arrangements of popular songs, however, modulate sometime during the song (often in a repeat of the final chorus) and thus end in a different key. This is an example of modulation.
In rock and popular music some pieces change back and forth, or modulate, between two keys. Examples of this include Fleetwood Mac's Dreams and The Rolling Stones' Under My Thumb. "This phenomenon occurs when a feature that allows multiple interpretations of key (usually a diatonic set as pitch source) is accompanied by other, more precise evidence in support of each possible interpretation (such as the use of one note as the root of the initiating harmony and persistent use of another note as pitch of melodic resolution and root of the final harmony of each phrase)."
Certain musical instruments play in a certain key, or have their music written in a certain key. Instruments that do not play in the key of C are known as transposing instruments. The most common kind of clarinet, for example, is said to play in the key of B♭. This means that a scale written in C major in sheet music actually sounds as a B♭ major scale when played on the B-flat clarinet—that is, notes sound a whole tone lower than written. Likewise, the horn, normally in the key of F, sounds notes a perfect fifth lower than written.
Similarly, some instruments are "built" in a certain key. For example, a brass instrument built in B♭ plays a fundamental note of B♭, and can play notes in the harmonic series starting on B♭ without using valves, fingerholes, or slides to alter the length of the vibrating column of air. An instrument built in a certain key often, but not always, uses music written in the same key (see trombone for an exception). However, some instruments, such as the diatonic harmonica and the harp, are in fact designed to play in only one key at a time: accidentals are difficult or impossible to play.
The highland bagpipes are built in B♭ major, though the music is written in D major with implied accidentals.
In Western musical composition, the key of a piece has important ramifications for its composition:
Key coloration is the difference between the intervals of different keys in a single non-equal tempered tuning, and the overall sound and "feel" of the key created by the tuning of its intervals.
Historical irregular musical temperaments usually have the narrowest fifths between the diatonic notes ("naturals") producing purer thirds, and wider fifths among the chromatic notes ("sharps and flats"). Each key then has a slightly different intonation, hence different keys have distinct characters. Such "key coloration" was an essential part of much eighteenth- and nineteenth-century music and was described in treatises of the period.
For example, in tunings with a wolf fifth, the key on the lowest note of the fifth sounds dramatically different from other keys (and is often avoided). In Pythagorean tuning on C (C, E+, G: 4, 5, 6), the major triad on C is just while the major triad on E♯+++ (F♮) is noticeably out of tune (E♯+++, A+, C: 4+1⁄8, 5, 6) due to E♯+++ (521.44 cents) being a Pythagorean comma (23.46 cents) larger sharp compared to F♮.
Music using equal temperament lacks key coloration because all keys have the same pattern of intonation, differing only in pitch.