我期待检测PyGame中的Alt键,但每次按下它时,它都会弹出通常会出现的菜单,如果单击左上角的图标窗口(还原,最大化等)。使用ALT键与PyGame
如何让PyGame识别按键,而不是窗口?
千恩万谢
我期待检测PyGame中的Alt键,但每次按下它时,它都会弹出通常会出现的菜单,如果单击左上角的图标窗口(还原,最大化等)。使用ALT键与PyGame
如何让PyGame识别按键,而不是窗口?
千恩万谢
我能想到的唯一的解决办法是pygame.event.set_grab(真)抓住所有的输入。 http://www.pygame.org/docs/ref/event.html
我不知道这是否也会阻止alt + tab和/或多媒体按钮,因此您应该谨慎处理。
我希望这将帮助,因为我可以检测ALT键没有任何影响unwished:
import pygame as p
from pygame.locals import *
p.init()
screen = p.display.set_mode((100,100))
run = True
while run == True:
for i in p.event.get():
if i.type == p.QUIT:#click x
run = False
if i.type == KEYDOWN:#2
print(i.key)
p.time.delay(30)
p.event.clear()
p.quit()
谢谢,发挥它的时候我试了一下 - 用鼠标周围的混乱。看起来在PyGame下使用ALT键不是很容易:( – RedCap 2010-11-02 02:30:14