Key cancellation form in lilypond

I have key changing example:

\score {
\relative c'' {
  \key bes \major
  g1
  \key g \major
  g1
}
}

It produces:

enter image description here

But i would like to have another template for this: first 2 becars, then staff bar, then sharp. Like this:

enter image description here

This is just another tradition. Does it possible in lilypond ?


Possible solutions

One solution is to force key to c major, add empty bar and only then change key to g major. (Thanks to “@mack” from #lilypond@irc.libera.chat)

\relative c'' {
  \key bes \major
  g1

  \key c \major \bar ""
  s16
  \bar "|"

  \key g \major 
  g1
}

Unfortunately, there is extra space between bar and becars:

enter image description here


Read more here: Source link