import keyboard # using module keyboard code example
Example 1: python get key module
import getkey, os
def clear():
if os.name == "nt":
_ = os.system('cls')
else:
_ = os.system('clear')
current = ""
while True:
clear()
print(current)
key = getkey.key()
if key == getkey.keys.BACKSPACE:
current = current[:-1]
elif key == getkey.keys.ENTER:
break
else:
current = current + key
clear()
clear()
print("\n\n\n You typed: " + current)
Example 2: python keyboard.write
keyboard.write('The quick brown fox jumps over the lazy dog.')