By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,467 Members | 994 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,467 IT Pros & Developers. It's quick & easy.

Solve Pynput Problem when changing language?

P: 1
Hi everyone,
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
elif key ==
string = ''.join([string,str(key).replace("'","")])
controller = keyboard.Controller()
# Collect events until released
listener = keyboard.Listener(on_press=on_press)


I run it and all good until I change the language.
The problem that I am facing is explained below.
If I start typing in english, the printed result is in english but when I change in greek the printed result remains english.
If I start typing in greek the printed result is 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.
Feb 19 '20 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.