I am working on a project (just started) in PYTHON and I want to create a keylogger for 2 languages english and greek. For this I have created the below (it is under "construction") code.
from pynput.keyboard import Key, Listener from langdetect import detect from pynput import keyboard def on_press(key): global string if key == keyboard.Key.esc: #if button escape is pressed close the program listener.stop() elif key == keyboard.Key.space: print(string) string="" else: string = ''.join([string,str(key).replace("'","")]) string="" controller = keyboard.Controller() # Collect events until released listener = keyboard.Listener(on_press=on_press) listener.start()
I run it and all good until I change the language. (please see the screenshots+explanations).
In the first picture I started typing in english and the printed result was in english but when I changed in greek the printed result remained english.
In the second picture I started in greek and the printed result was in greek, but when I change in english the result remains greek.
How can I solve this problem in order to take the same language result after an input language change?
Any help or advice would be great!
Thanks in advance.