[英]PyGame key.get_pressed method not working
My code is here: 我的代码在这里:
import pygame as pg
pg.init()
while 1:
print(True in pg.key.get_pressed())
key.get_pressed
returns a tuple of booleans, one for each key on the keyboard. key.get_pressed
返回一个布尔值的元组,键盘上的每个键一个。 True in
should check to see if any of them are true, but the result is always False
What am I doing wrong? True in
应该检查它们是否为真,但结果始终为False
我在做什么错?
If necessary, I am using python 3.4 and am on Windows. 如有必要,我在Windows上使用python 3.4。
key.get_pressed()
needs a window to work, so you should create one with key.get_pressed()
需要一个窗口才能工作,因此您应该使用
pg.display.set_mode((100,100)) # or whatever size you want
first. 第一。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.