[sugar] key-press-event' to listen to game pad keys?

Erik Blankinship erikb at mediamods.com
Thu Aug 23 17:55:22 EDT 2007


On 8/22/07, Julius B. Lucks <julius at younglucks.com> wrote:
>
>  Hi Erik,
> In pygame, we are using the keys
>
> pygame.K_KP9,  #KP_Page_Up
> pygame.K_KP3,  #KP_Page_Down
> pygame.K_KP1,  #KP_End
> pygame.K_KP7,  #KP_Home
>
> which (I believe) correspond to
>
> pygame.K_UP,
> pygame.K_DOWN,
> pygame.K_RIGHT,
> pygame.K_LEFT,
>
> I would assume the constants are similarly named for gtk.  Hope this
> helps,
>
> Julius
>


Thanks for your suggestion Julius.  I've modified my code:

    def _keyPressEventCb( self, widget, event ):
        keyname = gtk.gdk.keyval_name(event.keyval)
        print( "keyname:", keyname )

        #check: KP_End
        if (keyname == 'KP_Page_Up'):
            print("gamekey O")
        elif (keyname == 'KP_Page_Down'):
            print("gamekey X")
        elif (keyname == 'KP_End'):
            print("gamekey CHECK")
        elif (keyname == 'KP_Home'):
            print("gamekey SQUARE")

The maddening part is that sometimes I launch a sugar activity and this
works: keyname is equal to 'KP_Page_Down', etc.

But sometimes it doesn't work and Ikeyname is ^[[4~, etc. instead.

To whom do I file this in trac?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.laptop.org/pipermail/sugar/attachments/20070823/8cdcf9d5/attachment.htm 


More information about the Sugar mailing list