Tkinter determine keyboard layout Tkinter determine keyboard layout tkinter tkinter

Tkinter determine keyboard layout


No, there is no such feature built into Tkinter.

Why not simply have your application ask the user where each special key is, the first time the app starts up? Apple does this with OSX -- it asked me to press a couple of keys the very first time I booted up a fresh install.

You can put the focus into a widget and bind to <Any-KeyPress>, and from that grab enough information to bind to whatever key they pressed.


Seems that keysym is "??" if layout is not english.

def key_callback(e):    # Generate Ctrl-V if current layout is not english    if e.state & 4 > 0 and chr(e.keycode) == 'V' and e.keysym == "??":        root.focus_get().event_generate("<<Paste>>")root.bind("<Key>", key_callback)