使用 pygame 捕获所有按键操作

问题描述 投票:0回答:0

我正在像这样使用 pygame 捕获键盘输入:

pygame.init()
size = width, height = 320, 240 

screen = pygame.display.set_mode(size)
while True:
    for event in pygame.event.get():
        if event.type in (pygame.KEYUP, pygame.KEYDOWN):
            if event.type == pygame.KEYUP:
                press = False
            else:
                press = True
        # further processing

不幸的是,一些键,如 GUI 键(windows 键)或某些键组合,被操作系统捕获。但是,我需要 all 键才能被 pygame 窗口捕获。

我怎样才能做到这一点(在 Linux 上)?

python linux pygame keyboard keyevent
© www.soinside.com 2019 - 2024. All rights reserved.