This example shows how to use an observer to perform an action when a key is pressed. If a component is selected in the Glyph Editor, pressing Shift C will open a new glyph window with the selected component’s base glyph.

from mojo.UI import OpenGlyphWindow
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber

class BaseGlyphJumper(Subscriber):

    debug = True

    def glyphEditorDidKeyDown(self, info):
        # do nothing if the pressed character is not 'C'
        if not info["deviceState"]["keyDown"] == "C":

        # get the current glyph
        glyph = info["glyph"]

        # get the parent font
        font = glyph.font

        # loop over all components the glyph
        for component in glyph.components:

            # skip components which are not selected
            if not component.selected:

            # skip if the component’s base glyph is not in the font
            if component.baseGlyph not in font:

            # get the component’s base glyph
            baseGlyph = font[component.baseGlyph]

            # open the base glyph in a new glyph window
            OpenGlyphWindow(baseGlyph, newWindow=True)

if __name__ == '__main__':
Last edited on 15/07/2021