Can python detect which key is used on keyboard regardless of keyboard layout?

158 Views Asked by At

On the english keyboard 'y' is in the same place as 'z' on the slovenian keyboard (AZERTY). Is there a way a Python program can identify which physical key was pressed when you press the same key regardless of the language that is used?

1

There are 1 best solutions below

0
wjandrea On

From what I understand you're asking about running commands in the Python REPL (AKA shell). AFAIK the Python REPL doesn't interact directly with hardware; instead it interacts with OS libraries. In this case that means it doesn't receive key scancodes but characters. So instead of trying to change Python, change the keyboard layout of your OS. How to do that depends on the OS.