I googled it. First result:
First answer says:
def get_capslock_state():
import ctypes
hllDll = ctypes.WinDLL ("User32.dll")
VK_CAPITAL = 0x14
return hllDll.GetKeyState(VK_CAPITAL)
And someone else posted how to do the same thing on linux on the other thread, not that google couldn’t also spill out a similar answer.
Now we know whether the led is on or off, all that remains is upper casing the input.
s = input.upper() if allcaps else input;
That’s about it.