python Tkinter Capturing keyboard events save as one single string python Tkinter Capturing keyboard events save as one single string tkinter tkinter

python Tkinter Capturing keyboard events save as one single string


Currently, you are creating text variable , everytime the key() function gets called, and text it only stores the last character you typed.

You can define text as a module level variable , and use that module level text inside your key function -

text = ''def key(event):    global text    text+= event.char    print("pressed", text)