检测输入键(Python 3.4.2)
Detecting input keys (Python 3.4.2)
这可能很简单,但我找不到答案。我基本上想要一些代码来检测不同的按键(输入、左键等),然后将键的类型保存在一个变量中。
如果您在 Windows 并且只想在 window 有键盘焦点时获得输入,您可以使用 msvcrt.getch
:
Read a keypress and return the resulting character. Nothing is echoed to the console.
这可能很简单,但我找不到答案。我基本上想要一些代码来检测不同的按键(输入、左键等),然后将键的类型保存在一个变量中。
如果您在 Windows 并且只想在 window 有键盘焦点时获得输入,您可以使用 msvcrt.getch
:
Read a keypress and return the resulting character. Nothing is echoed to the console.