fonksiyonunu tespit anahtarının sonra gelir ve burada çalıştığını varsayalım benPython 3.x Anahtar Tespiti. Baskı deyimi Mac Terminalinde Python 3.x basarak anahtar algılamak çalıştı
import tty
import termios
import sys
def get_key():
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
try:
tty.setraw(sys.stdin.fileno())
ch = sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
return ch
def key_detect():
print("Key detect: ", end="")
print(get_key())
while True:
key_detect()
sahip kodudur gibi:
Key detect:
ve bir şeye bastığında, baskı sonucu alıncaya kadar bekleyin ve bir dahaki sefere beklemeniz gerekir. Şunun gibi:
Key detect: a
Key detect:
Ama böyle gitti:
// A cursor flashes, but nothing has been printed
Ve bir şey basıldığında:
Key detect: a
*cursor*
Veya Python 3.3 üzerinde ve yukarı doğru 'print' işlevine' floş = TRUE sağlayabilmektedir. – user2357112
teşekkürler çok çalışıyor :) – terryy