Next: , Previous: Clef, Up: Staff notation


6.4.2 Key signature

The key signature indicates the tonality in which a piece is played. It is denoted by a set of alterations (flats or sharps) at the start of the staff.

Setting or changing the key signature is done with the \key command

\key pitch type

Here, type should be \major or \minor to get pitch-major or pitch-minor, respectively. You may also use the standard mode names (also called “church modes”): \ionian, \locrian, \aeolian, \mixolydian, \lydian, \phrygian, and \dorian.

This command sets the context property Staff.keySignature. Non-standard key signatures can be specified by setting this property directly.

Accidentals and key signatures often confuse new users, because unaltered notes get natural signs depending on the key signature. For more information, see Accidentals or Accidentals and key signatures.

     
     \key g \major
     f1
     fis

[image of music]

Commonly tweaked properties

A natural sign is printed to cancel any previous accidentals. This can be suppressed by setting the Staff.printKeyCancellation property.

     
     \key d \major
     a b cis d
     \key g \minor
     a bes c d
     \set Staff.printKeyCancellation = ##f
     \key d \major
     a b cis d
     \key g \minor
     a bes c d

[image of music]

See also

Program reference: KeyCancellation, KeySignature.


Next: , Previous: Clef, Up: Staff notation

This page is for LilyPond-2.10.33 (stable-branch).

Report errors to http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs.

Other languages: French.