help please with keyDown Observer

RoboFont Forums Help / General help please with keyDown Observer

This topic contains 2 replies, has 2 voices, and was last updated by  jo 6 years, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #5915

    jo
    Participant

    I am trying to get the “chars” or “keyCode” value when a key is pressed. So return which key was pressed.
    I see the info[“event”] NSEvent but can’t get anywhere from there.
    I tried to get an idea from the developer site to no avail.
    Is there an example file or some other help.
    Please. Thanks. jo

    #5916

    frederik
    Keymaster

    This should do it to catch keydowns in a glyph view

    
    from mojo.events import addObserver
    
    class testKeyDown:
        
        def __init__(self):
            
            addObserver(self, "keyDown", "keyDown")
            
        def keyDown(self, notification):
            event = notification["event"]
            print event.keyCode()
            print event.characters()
        
    testKeyDown()
    

    good luck!

    #5917

    jo
    Participant

    hey frederik,
    I was sooo close …
    Thanks a lot for your help, working perfectly now.
    jo

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.