I want to capture the pressed key and do different tasks if it for example is '1'
or '2'
, etc.
This is my sample code:
import keyboard
key = keyboard.read_key()
if key == '1':
print('something')
elif key == '2':
print('something')
else:
print('something')
str = input('Type something: ')
It works fine but for example when I press key '1', when the last line (input) runs, the output is like this (Terminal):
Type something: 1
Why Python automatically puts '1' at the end and how can I get rid of it?
Appreciate any help!