Jump to content

Key signatures: Difference between revisions

From LilyPond wiki
Import snippet from LSR
 
m Replace version="2.24.0" with version="2.24" now that the LilyWiki extension supports auto-selecting the latest release in a stable series
Line 10: Line 10:
Accidentals and key signatures often confuse new users, because unaltered notes get natural signs depending on the key signature.
Accidentals and key signatures often confuse new users, because unaltered notes get natural signs depending on the key signature.


<lilypond version="2.24.0">
<lilypond version="2.24">
%% http://lsr.di.unimi.it/LSR/Item?id=175
%% http://lsr.di.unimi.it/LSR/Item?id=175



Revision as of 18:56, 16 November 2025

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.

\version "2.24"

%% http://lsr.di.unimi.it/LSR/Item?id=175

\relative c''{
  \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
}