0

Is there a command for python shell that allows key input without using enter, like a tkinter bind or a cmd choice. any suggestions

I've tried a tkinter bind. pynput is not out for python 3.7 yet :(. any other suggestions? This did not work.

canvas.bind_all('<KeyPress-Left>',Left)
canvas.bind_all('<KeyPress-Right',Right)
def Right():
    if R == 0:
        X = X + 1
def Left():
    if L == 0:
        X = X - 1

I expected it to change x, but it didn't change. (x is declared before these statements are called.)

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
KillerQuow
  • 37
  • 8

1 Answers1

0

use this if your os is windows

msvcrt.getch() Read a keypress and return the resulting character. Nothing is echoed to the console. This call will block if a keypress is not already available, but will not wait for Enter to be pressed. If the pressed key was a special function key, this will return '\000' or '\xe0'; the next call will return the keycode. The Control-C keypress cannot be read with this function.

check --> https://docs.python.org/2/library/msvcrt.html