# Theoretical key

In music theory, a theoretical key is a key whose key signature requires double-flats, or double-sharps.
Some musical keys are not normally used because they would require a double sharp or double flat in the key signature. For example, G♯ major requires eight sharps, and, since there are only seven scale tones, one tone requires a double sharp (F). In 12-tone equal temperament, the standard tuning of Western music, the key of G♯ major is enharmonically equivalent to A♭ major (with four flats). In the absence of other factors, this key would generally be notated as A♭.
| G♯ major, a key signature with a double-sharp | A♭ major, equivalent key |
| G♯ major: | G♯ | A♯ | B♯ | C♯ | D♯ | E♯ | F |
| A♭ major: | A♭ | B♭ | C | D♭ | E♭ | F | G |

## Modulation

While a piece of Western music generally has a home key, a passage within it may modulate to another key, which is usually closely related to the home key (in the Baroque and early Classical eras), that is, close to the original in the circle of fifths. When the key has zero or few sharps or flats, the notation of both keys is straightforward. But if the home key has many sharps or flats, particularly if the new key is on the opposite side, double sharps or flats may be necessary, or an enharmonically equivalent key may be used to avoid double sharps or flats.
In the bottom three places on the circle of fifths the enharmonic equivalents can be notated with single sharps or flats and so are not theoretical keys:
| Major (minor) | Key signature | Major (minor) | Key signature |
| B (g♯) | 5 sharps | C♭ (a♭) | 7 flats |
| F♯ (d♯) | 6 sharps | G♭ (e♭) | 6 flats |
| C♯ (a♯) | 7 sharps | D♭ (b♭) | 5 flats |

## The need to consider theoretical keys

When a parallel key ascends the opposite side of the circle from its home key, theory suggests that double-sharps and double-flats would have to be incorporated into the notated key signature. The following theoretical keys would require up to seven double-sharps or double-flats. Six of these are the parallel major/minor keys of those above.
| Major | Key signature | Minor |
| F♭ major (E major) | 8 flats (4 sharps) | D♭ minor (C♯ minor) |
| B major (A major) | 9 flats (3 sharps) | G♭ minor (F♯ minor) |
| E major (D major) | 10 flats (2 sharps) | C♭ minor (B minor) |
| A major (G major) | 11 flats (1 sharp) | F♭ minor (E minor) |
| D major (C major) | 12 flats (no flats or sharps) | B minor (A minor) |
| G major (F major) | 13 flats (1 flat) | E minor (D minor) |
| C major (B♭ major) | 14 flats (2 flats) | A minor (G minor) |
| G♯ major (A♭ major) | 8 sharps (4 flats) | E♯ minor (F minor) |
| D♯ major (E♭ major) | 9 sharps (3 flats) | B♯ minor (C minor) |
| A♯ major (B♭ major) | 10 sharps (2 flats) | F minor (G minor) |
| E♯ major (F major) | 11 sharps (1 flat) | C minor (D minor) |
| B♯ major (C major) | 12 sharps (no flats or sharps) | G minor (A minor) |
| F major (G major) | 13 sharps (1 sharp) | D minor (E minor) |
| C major (D major) | 14 sharps (2 sharps) | A minor (B minor) |
A piece in a major key might modulate up a fifth to the dominant (a common occurrence in Western music), resulting in a new key signature with an additional sharp. If the original key was C-sharp, such a modulation would lead to the theoretical key of G-sharp major (with eight sharps) requiring an F in place of the F♯. This section could be written using the enharmonically equivalent key signature of A-flat major instead. Claude Debussy's Suite bergamasque does this: in the third movement "Clair de lune" the key shifts from D-flat major to D-flat minor (eight flats) for a few measures but the passage is notated in C-sharp minor (four sharps); the same happens in the final movement, "Passepied", in which a G-sharp major section is written as A-flat major.
Such passages may instead be notated with the use of double-sharp or double-flat accidentals, as in this example from Johann Sebastian Bach's Well-Tempered Clavier, which has this passage in G-sharp major in measures 10-12.
While theoretical keys are sometimes notated with accidentals as in this example, the use of actual theoretical key signatures is very rare. The final pages of John Foulds' A World Requiem are written in G♯ major (with F in the key signature), No. 18 of Anton Reicha's Practische Beispiele is written in B# major, and the third movement of Victor Ewald's Brass Quintet Op. 8 is written in F♭ major (with B in the key signature). Examples of theoretical key signatures are pictured below:
There does not appear to be a standard on how to notate theoretical key signatures:
* The default behaviour of LilyPond (pictured above) writes all single sharps or flats in the circle-of-fifths order before showing the double signs. This is the format used in John Foulds' A World Requiem, Op. 60, which uses the key signature of G♯ major as displayed above. The sharps in the key signature of G♯ major proceed C♯, G♯, D♯, A♯, E♯, B♯, F.
* The single signs at the beginning are sometimes repeated as a courtesy, e.g. Max Reger's Supplement to the Theory of Modulation, which contains D♭ minor key signatures on pp. 42–45. These have a B♭ at the start and also a B at the end (with a double-flat symbol), going B♭, E♭, A♭, D♭, G♭, C♭, F♭, B.
* Sometimes the double signs are written at the beginning of the key signature, followed by the single signs. For example, F♭ would be notated as B, E♭, A♭, D♭, G♭, C♭, F♭. This convention is used by Victor Ewald and by some theoretical works.
* No. 18 of Anton Reicha's Practische Beispiele in B♯ major shows B♯, E♯, A, D, G, C, F.

## Tunings other than twelve-tone equal-temperament

In tuning systems where the number of notes per octave is not a multiple of 12, keys such as G♯ and A♭ are not enharmonically equivalent. These tunings may also have keys with no analogue in 12-tone equal temperament, which can lead to situations where double sharps, double flats, or microtonal alterations need to be used in key signatures. For example, the key of A♯ major, with 10 sharps, is equivalent to B♭ major in 12-tone equal temperament, but in 19-tone equal temperament, it is equivalent to B major, with nine flats.

## Other examples and considerations

* The key of E appears in John Stump's "Prelude and the Last Hope" with multiple double flats, although it appears in a measure of whole rests with no pitches to read.
* There can be countless such keys, using triple accidentals and beyond.
* In just intonation, there are no enharmonic keys.