Read console input using pygame

后端 未结 5 1556
故里飘歌
故里飘歌 2021-01-13 08:56

Is there anyway to use pygame to get input from the console, rather than having to display a separate window to get input? I\'m using pygame to track how long the keys on th

5条回答
  •  走了就别回头了
    2021-01-13 09:02

    Pygame is designed for making (graphical) games, so it only captures key presses when there is a window displayed. As Ignacio said in his answer, reading from the command line and from another window are very different things.

    If you want to create a command line application, try curses:

    http://docs.python.org/library/curses.html

    Unfortunately, it only works on Linux and Mac OS X.

提交回复
热议问题