Py学习  »  Python

如何在python程序中检测“space”?

Roberto Chavo • 5 年前 • 1614 次点击  

我正在创建一个基于文本的游戏,为了加速过去的对话,我希望用户能够点击'空间'并跳过它。

import time
import sys

text_speed = .05

def slow_type(line, speed): #You input the dialogue and speed(smaller = faster)
    for l in line:
        sys.stdout.write(l)
        sys.stdout.flush()
        time.sleep(speed)
    time.sleep(.5)

if <'Space'> pressed:
    text_speed = 0

NL1 = "Huh, I see you finally came. "

slow_type(NL1, text_speed)
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/40285
 
1614 次点击  
文章 [ 3 ]  |  最新文章 5 年前