[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] KMOD_CTRL
Daniel Dornhardt wrote:
Mauricio Gomes wrote:
I am looking to customize my Freevo system to be controlled through
an IR
remote that sends ASCII key commands to the machine. Freevo uses
pygame for
keyboard input and mailing their list has provided me with no
results. So I
will try here.
I am not a Python programmer and so I am not too familiar with all
the data
types. It seems as though Freevo uses a dictionary to map keys like
bleh.K_f to whatever the corresponding Freevo command is. My
question is
how can I modify this so that instead of just the 'f' key, I can use the
modifier KMOD_CTRL + K_F?
Knowing this will allow people to use their GCT-Allwell remotes with
PyGame/Freevo. Thanks in advance.
Mauricio Gomes
maybe something like:
if event.type == KEYDOWN:
if event.key == K_f:
mods = pygame.key.get_mods() # an integer
representing the
if mods & (K_RCTRL | K_LCTRL): # pressed modifier keys
(shift, alt, ctrl...)
do_stuff()
ok, i was wrong, you NEED to use the KMOD constants, not the K -
Keycodes, KMOD_RCTRL != K_RCTRL.
pygame.key.get_mods() gives the a bitmask of the modifiers pressed at
the time called, and you have to find out which they are, that's what
the KMOD_* - constants are used for.
if event.type == KEYDOWN:
if event.key == K_f:
mods = pygame.key.get_mods() # an integer representing
the
if mods & (KMOD_RCTRL | KMOD_LCTRL): # pressed modifier keys
(shift, alt, ctrl...)
do_stuff()
should work, but not tested in any way