flasavode
flasavode

Reputation: 39

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

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?

Upvotes: 3

Views: 170

Answers (1)

wjandrea
wjandrea

Reputation: 32921

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.

Upvotes: -3

Related Questions