#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2005
    Location
    Amsterdam, the Netherlands
    Posts
    12
    Rep Power
    0

    key combination as key event in wxpython


    I have some question about handling key events in wxPython

    I want to be able to handle key event caused by custom key combinations, for instance 'INS + right arrow'

    So far all I can find in the documentation is that I can check whether a special key is curently being pressed during a WXK_KEY_UP event handler, as shown the the following example

    Code:
    def onKeyUp(event):
        if event.KeyCode() == wx.WXK_RIGHT:
            if event.AltDown(): 
                print "ALT - right arrow combination detected!"
    But such event.XXXDown() functions are only available for the ALT, CTRL and SHIFT key.

    How do I check whether a different key is currently being pressed?

    And another thing: is it possible if a certain key is "double pressed"? For instance to detect if the right arrow button was released twice quickly?
  2. #2
  3. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    Can't you use the and keyword? If thiskeyisdown and thiskeyisdown then do something.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2005
    Location
    Amsterdam, the Netherlands
    Posts
    12
    Rep Power
    0
    That would be a solution, however so far I haven't found such a 'thiskeyisdown' kind of method that I can use, apart from AltDown, ShiftDown, CmdDown, MetaDown and ControlDown. What I'm looking for is a way to check if any other key besides those is currently down.
  6. #4
  7. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    I'm too busy at the moment to go and check. But isn't there a function that returns a boolean (true/false) value of whether a key is pressed down or not? Did you try checking the wxPython samples for such an example? I'm pretty sure I remember seeing this there.

IMN logo majestic logo threadwatch logo seochat tools logo