Menu

PyCap and keycodes

Help
2010-01-06
2013-05-08
  • Pavel Kolchanov

    Pavel Kolchanov - 2010-01-06

    Python Demo 1 work not correctly - SDL and Windows keycodes are different. At this moment, I made simple pygame.locals-like file from SDL_keysym.h (tried to use pygame.locals directly, but there were some errors).

    Oops, sorry for formatting with tabs…
    This code is easy to use - write it down, for example, in file "keysyms.py", and import it in the game:

    from keysyms import *
    

    Next, it can be used in key processing:

    def keyDown( key ):
        # if arrow keys have changed, store them in our global variables
        if key == K_LEFT:
            global leftDown
            leftDown = 1
        elif key == K_RIGHT:
            global rightDown
            rightDown = 1
        elif key == K_UP:
            global upDown
            upDown = 1
        elif key == K_DOWN:
            global downDown
            downDown = 1
        elif key == K_ESCAPE:
            global doExit
            doExit = 1
    
     
  • W.P. van Paassen

    Thanks!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.