相关疑难解决方法(0)

在python中检测按键?

我在python中制作秒表类型程序,我想知道如何检测是否按下了一个键(例如p表示暂停,s表示停止),我不希望它像raw_input那样等待用户在继续执行之前的输入.任何人都知道如何在while循环中执行此操作?

另外,我想制作这个跨平台,但如果不可能,那么我的主要开发目标是linux

python keypress detect python-2.7

64
推荐指数
10
解决办法
24万
查看次数

从终端检测python中键盘输入的最简单方法是什么?

I have a simple python script, that has some functions that run in a loop (I'm taking sensor readings).

while True:
    print "Doing a function"
Run Code Online (Sandbox Code Playgroud)

If the keyboard is pressed I'd like to print "key pressed".

What's the simplest way of doing this in Python? I've searched high and low. I've found out how to do it with pygame, but I'd rather do it without. If I do have to use pygame is it possible to not have a separate …

python keyboard terminal

49
推荐指数
7
解决办法
12万
查看次数

标签 统计

python ×2

detect ×1

keyboard ×1

keypress ×1

python-2.7 ×1

terminal ×1