Search code examples
pythonpython-3.xstringkeyboard

How to find shift value for all keyboard characters and symbols?


What is the easiest way to get the "uppercase" value of all keys and symbols on a keyboard using Python?

I am aware that this works for standard letters

mystr = "a"
print(mystr.upper()) # "A"

But what if I want to convert "1" into "!"? What is the best way to do this? mystr.upper() in this case outputs "1" still.


Solution

  • You can't do this from purely Python. The physical characteristics of the keyboard are embedded in the keyboard's circuitry, not anywhere you can programmatically inquire about that mapping. You would need to implement a way for each client to specify the attached device, or allow you to probe the system, to find the model specs. Then would you need to look up and download the mapping from the manufacturer specs.

    Also, what mandates that your input characters are coming from a keyboard? There are many possible input streams.