1import getkey, os
2def clear():
3 if os.name == "nt":
4 _ = os.system('cls') #Clear function
5 else:
6 _ = os.system('clear')
7current = ""
8while True:
9 clear() #Clearing, required at beginning at end in order for algorithm to work
10 print(current)
11 key = getkey.key() # Gets the key
12 if key == getkey.keys.BACKSPACE: # Detects if key is backspace
13 current = current[:-1]
14 elif key == getkey.keys.ENTER: # Detecs if key is the enter(return) key
15 break
16 else:
17 current = current + key # Otherwise, adds on the the current variable
18 clear()
19clear()
20print("\n\n\n You typed: " + current)
21