In music theory, the key of a piece usually refers to the tonic note and chord, which gives a subjective sense of arrival and rest. Other notes and chords in the piece create varying degrees of tension, resolved when the tonic note and/or chord returns. The key may be major or minor, although major is assumed in a phrase like "this piece is in C." Popular songs are usually in a key, and so is classical music during the common practice period, about 1650–1900. Longer pieces in the classical repertoire may have sections in contrasting keys.
The methods by which the key is established for a particular piece are not easy to explain, and vary considerably over the period of music history; however, the chords most often used in a piece in a particular key are those containing the notes in the corresponding scale, and conventional progressions of these chords, particularly cadences, serve to orient the listener around the tonic.
The key signature is not 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 will be 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 may be said to be "in a key", an unrelated usage meaning it is a transposing instrument.
Keys and tonality 
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. Although the key of a piece may be named in the title (e.g., Symphony in C), 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). A key may be major or minor; music can be described as being in the Dorian mode, or Phrygian, et cetera, and is thus usually considered to be in a specific mode rather than a key. In languages other than English, other key naming systems may be used.
The notes and chords used within a key are generally drawn from the major or minor scale associated with the tonic triad, but may also include borrowed chords, altered chords, secondary dominants, and the like. All of these notes and chords, however, are used in conventional patterns that serve to establish the primacy of the tonic note and triad.
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, will shift up a half-step or a whole step sometime during the song (often in a repeat of the final chorus) and thus will end in a different key. This is an example of modulation.
It should be noted that the key of the piece ... contributes an indefinable something to the evocative quality. This is very difficult to put into concrete terms, but slow movements in A-flat major do have something in common, as do fast movements in C minor, concerto allegros in D major, etc. There has been disagreement on this point. It has been argued, since standards of pitch level have changed over the centuries, that today we actually hear pieces written two centuries ago in a different (usually higher) key than than intended by the composer. It has been argued that the performer's concept of particular key is actually created by factors such as the 'feel' of the key or tonal center on the keyboard or its appearance in notation. Many musicians, however, tend toward an empirical acceptance of specific moods associated with specific keys, regardless of changes in pitch standards and other factors.—John D. White (1976) Emphasis added.
In rock and popular music some pieces, "tend to float back and forth between two keys", with examples including 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)."
Instruments in a key 
Certain musical instruments are sometimes said to 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-flat. This means that a scale written in C major in sheet music will actually sound as a B-flat 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 may be said to be built in a certain key. For example, a brass instrument built in B-flat will play a fundamental note of B-flat, and will be able to play notes in the harmonic series starting on B-flat without using valves, fingerholes, or slides or otherwise altering the length of the vibrating column of air. An instrument built in a certain key will often, but not always, have its 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 E-flat major, although the music is written in D major.
In Western musical composition, the key of a song has important ramifications for its composition:
- As noted earlier, certain instruments are said to be designed for a certain key, as playing in that key can be physically easier or harder. Thus the choice of key can be an important one when composing for an orchestra, as one must take these elements into consideration.
- In the life of the professional clarinettist, for example, it is common to carry two instruments tuned a semitone apart (B-flat and A) to cope with the needs of composers: Mozart's well-known clarinet concerto is in A Major. To play it on a B-flat instrument would be difficult, and to rewrite all the orchestral parts to allow the piece to be played in B-flat major would be an enormous effort. Even so, it is not unheard of for a piece published in B-flat to include notes a semitone (or more) below the range of the common B-flat clarinet. The piece must then be played on a more exotic instrument, or transposed by hand (or at sight) for the slightly larger 'A' clarinet. There are clarinets with an extended range, with a longer bore and additional keys.
- Besides this though, the timbre of almost any instrument is not exactly the same for all notes played on that instrument. For this reason a song that might be in the key of C might sound or "feel" somewhat different (besides being in a different pitch) to an observer if it is transposed to the key of A.
- In addition, since many composers often utilized the piano while composing, the key chosen can possibly have an effect over the composing. This is because the physical fingering is different for each key, which may lend itself to choosing to play and thus eventually write certain notes or chord progressions compared to others, or this may be done on purpose to make the fingering more efficient if the final piece is intended for piano.
- In music that does not use equal temperament, chords played in different keys are qualitatively different.
Key coloration 
Key coloration is the difference between the intervals of different keys in a single non-equal tempered tuning, and the overall sound and "feel" 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 will have a dramatically different sound than the 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.125, 5, 6) due to E♯+++ (521.44 cents) being a Pythagorean comma(23.46 cents) larger sharp compared to F♮.
Modern music lacks key coloration because it uses equal temperament in which all keys have the same pattern of intonation, differing only in pitch.
- Willi Apel, Harvard Dictionary of Music (Cambridge: Harvard University Press, 1969), 450.
- White, John D. (1976) The Analysis of Music, p. 94. ISBN 0-13-033233-X.
- Ken Stephenson, What to Listen for in Rock: A Stylistic Analysis (New Haven: Yale University Press, 2002), 48. ISBN 978-0-300-09239-4.
- Kent Wheeler Kennan, The Technique of Orchestration, second edition (Englewood Cliffs, New Jersey: Prentice-Hall, Inc., 1970), 1952; ISBN 0-13-900316-9.
Further reading 
- Innig, Renate (1970). System der Funktionsbezeichnung in den Harmonielehren seit Hugo Riemann. Düsseldorf: Gesellschaft zur Förderung der systematischen Musikwissenschaft.
- Rahn, John (1980). Basic Atonal Theory. New York: Longman; London and Toronto: Prentice Hall International. ISBN 0-02-873160-3. Reprinted 1987, New York: Schirmer Books; London: Collier Macmillan.
- Steblin, Rita (1983). A History of Key Characteristics in the 18th and Early 19th Centuries. UMI Research Press, Ann Arbor.
- Christian Schubart's "Affective Key Characteristic"
- Characteristics of Musical Keys - from various sources.
Key coloration 
|Diatonic scales and keys|
|The table indicates the number of sharps or flats in each scale. Minor scales are written in lower case.|