[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Earliest access to state of keyboard?



Thanks.


From: Brian Fisher <brian@xxxxxxxxxxxxxxxxxxx>
To: pygame-users@xxxxxxxx
Sent: Wednesday, July 3, 2013 7:43 PM
Subject: Re: [pygame] Earliest access to state of keyboard?

I think the problem is that the way SDL works, since it never got the alt down event, so it will never think alt is held :(

as a test, I tried modifying a little game script to print pygame.key.get_mods() continuously in the game loop, and it was always 0 for the alt key being held before the script ran.

If you really want something like this, I'd turn to platform specific function calling through ctypes. This should do it on windows:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646301(v=vs.85).aspx


On Wed, Jul 3, 2013 at 8:16 AM, Keith Nemitz <musenik@xxxxxxxxx> wrote:

I'd like to poll the keyboard before opening a window, in order to determine if the game should launch in Window or Fullscreen mode.  This code prints 0:

pygame.event.pump();
print pygame.key.get_mods();

#then open window
pygl2d.window.init(...)


I suspected there had to be a window before the event system works. But this code also prints 0:

    pygame.init();
    pygame.display.set_mode([1024, 768], DOUBLEBUF); #fake window to allow access to keys
    pygame.event.pump();
    print pygame.key.get_mods();

    #now change window to reflect keypress...


suggestions?