Have you tried the pyHooks module? It can hook the keyboard at what might be a lower level than pygame. I know, for example, that it works whether or not the application has focus.
There's a demo script that prints all the info about a given keystroke, maybe there's something in it that differentiates multiple keyboards. Apologies if this was already mentioned. On Sat, Nov 19, 2011 at 2:15 PM, Miriam English <m...@miriam-english.org>wrote: > It looks like the serial value changes each time you use a different > keyboard. I tried pressing "1" then "2" on one keyboard and found the > serial number doesn't change. Interesting. > > Unfortunately when you input from another keyboard the serial number just > seems to increment. With just 2 keyboards I guess this should be a matter > of _even_ serial numbers being from one keyboard, and _odd_ serial numbers > being from the other keyboard. > > I'm not sure how you detect the serial numbers from python though. Perhaps > someone else here knows more about this stuff. > > Best wishes, > > - Miriam > > > pierrelafran...@sympatico.ca wrote: > >> >> KeyPress event, serial 38, synthetic NO, window 0x5200001, >> root 0x10b, subw 0x0, time 443293042, (833,223), root:(839,249), >> state 0x10, keycode 87 (keysym 0xffb1, KP_1), same_screen YES, >> XLookupString gives 1 bytes: (31) "1" >> XmbLookupString gives 1 bytes: (31) "1" >> XFilterEvent returns: False >> >> KeyRelease event, serial 39, synthetic NO, window 0x5200001, >> root 0x10b, subw 0x0, time 443293186, (833,223), root:(839,249), >> state 0x10, keycode 87 (keysym 0xffb1, KP_1), same_screen YES, >> XLookupString gives 1 bytes: (31) "1" >> XFilterEvent returns: False >> >> MappingNotify event, serial 39, synthetic NO, window 0x0, >> request MappingKeyboard, first_keycode 8, count 248 >> >> KeyPress event, serial 39, synthetic NO, window 0x5200001, >> root 0x10b, subw 0x0, time 443294033, (833,223), root:(839,249), >> state 0x10, keycode 88 (keysym 0xffb2, KP_2), same_screen YES, >> XLookupString gives 1 bytes: (32) "2" >> XmbLookupString gives 1 bytes: (32) "2" >> XFilterEvent returns: False >> >> KeyRelease event, serial 40, synthetic NO, window 0x5200001, >> root 0x10b, subw 0x0, time 443294153, (833,223), root:(839,249), >> state 0x10, keycode 88 (keysym 0xffb2, KP_2), same_screen YES, >> XLookupString gives 1 bytes: (32) "2" >> XFilterEvent returns: False >> >> MappingNotify event, serial 40, synthetic NO, window 0x0, >> request MappingKeyboard, first_keycode 8, count 248 >> >> KeyPress event, serial 40, synthetic NO, window 0x5200001, >> root 0x10b, subw 0x0, time 443294689, (833,223), root:(839,249), >> state 0x10, keycode 87 (keysym 0xffb1, KP_1), same_screen YES, >> XLookupString gives 1 bytes: (31) "1" >> XmbLookupString gives 1 bytes: (31) "1" >> XFilterEvent returns: False >> >> KeyRelease event, serial 41, synthetic NO, window 0x5200001, >> root 0x10b, subw 0x0, time 443294817, (833,223), root:(839,249), >> state 0x10, keycode 87 (keysym 0xffb1, KP_1), same_screen YES, >> XLookupString gives 1 bytes: (31) "1" >> XFilterEvent returns: False >> >> MappingNotify event, serial 41, synthetic NO, window 0x0, >> request MappingKeyboard, first_keycode 8, count 248 >> >> KeyPress event, serial 41, synthetic NO, window 0x5200001, >> root 0x10b, subw 0x0, time 443295313, (833,223), root:(839,249), >> state 0x10, keycode 88 (keysym 0xffb2, KP_2), same_screen YES, >> XLookupString gives 1 bytes: (32) "2" >> XmbLookupString gives 1 bytes: (32) "2" >> XFilterEvent returns: False >> >> KeyRelease event, serial 42, synthetic NO, window 0x5200001, >> root 0x10b, subw 0x0, time 443295441, (833,223), root:(839,249), >> state 0x10, keycode 88 (keysym 0xffb2, KP_2), same_screen YES, >> XLookupString gives 1 bytes: (32) "2" >> XFilterEvent returns: False >> >> MappingNotify event, serial 42, synthetic NO, window 0x0, >> request MappingKeyboard, first_keycode 8, count 248 >> >> KeyPress event, serial 42, synthetic NO, window 0x5200001, >> root 0x10b, subw 0x0, time 443295937, (833,223), root:(839,249), >> state 0x10, keycode 87 (keysym 0xffb1, KP_1), same_screen YES, >> XLookupString gives 1 bytes: (31) "1" >> XmbLookupString gives 1 bytes: (31) "1" >> XFilterEvent returns: False >> >> KeyRelease event, serial 43, synthetic NO, window 0x5200001, >> root 0x10b, subw 0x0, time 443296081, (833,223), root:(839,249), >> state 0x10, keycode 87 (keysym 0xffb1, KP_1), same_screen YES, >> XLookupString gives 1 bytes: (31) "1" >> XFilterEvent returns: False >> >> MappingNotify event, serial 43, synthetic NO, window 0x0, >> request MappingKeyboard, first_keycode 8, count 248 >> >> KeyPress event, serial 43, synthetic NO, window 0x5200001, >> root 0x10b, subw 0x0, time 443296537, (833,223), root:(839,249), >> state 0x10, keycode 88 (keysym 0xffb2, KP_2), same_screen YES, >> XLookupString gives 1 bytes: (32) "2" >> XmbLookupString gives 1 bytes: (32) "2" >> XFilterEvent returns: False >> >> KeyRelease event, serial 44, synthetic NO, window 0x5200001, >> root 0x10b, subw 0x0, time 443296641, (833,223), root:(839,249), >> state 0x10, keycode 88 (keysym 0xffb2, KP_2), same_screen YES, >> XLookupString gives 1 bytes: (32) "2" >> XFilterEvent returns: False >> >> MappingNotify event, serial 44, synthetic NO, window 0x0, >> request MappingKeyboard, first_keycode 8, count 248 >> >> KeyPress event, serial 44, synthetic NO, window 0x5200001, >> root 0x10b, subw 0x0, time 443297553, (833,223), root:(839,249), >> state 0x10, keycode 87 (keysym 0xffb1, KP_1), same_screen YES, >> XLookupString gives 1 bytes: (31) "1" >> XmbLookupString gives 1 bytes: (31) "1" >> XFilterEvent returns: False >> >> KeyRelease event, serial 45, synthetic NO, window 0x5200001, >> root 0x10b, subw 0x0, time 443297633, (833,223), root:(839,249), >> state 0x10, keycode 87 (keysym 0xffb1, KP_1), same_screen YES, >> XLookupString gives 1 bytes: (31) "1" >> XFilterEvent returns: False >> >> MappingNotify event, serial 45, synthetic NO, window 0x0, >> request MappingKeyboard, first_keycode 8, count 248 >> >> KeyPress event, serial 45, synthetic NO, window 0x5200001, >> root 0x10b, subw 0x0, time 443298049, (833,223), root:(839,249), >> state 0x10, keycode 88 (keysym 0xffb2, KP_2), same_screen YES, >> XLookupString gives 1 bytes: (32) "2" >> XmbLookupString gives 1 bytes: (32) "2" >> XFilterEvent returns: False >> >> KeyRelease event, serial 46, synthetic NO, window 0x5200001, >> root 0x10b, subw 0x0, time 443298153, (833,223), root:(839,249), >> state 0x10, keycode 88 (keysym 0xffb2, KP_2), same_screen YES, >> XLookupString gives 1 bytes: (32) "2" >> XFilterEvent returns: False >> > > > -- > If you don't have any failures then you're not trying hard enough. > - Dr. Charles Elachi, director of NASA's Jet Propulsion Laboratory > ----- > Website: http://miriam-english.org > Blogs: http://miriam-e.dreamwidth.org > http://miriam-e.livejournal.**com<http://miriam-e.livejournal.com> >