Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tkinter windows key event

What is the event for the Windows key in Tkinter? I'm using Linux, but I would like answers for both Linux and Windows. If Mac has a similar key, feel free to let me know the binding for it. I imagine there are different events for the left and right windows keys.

The windows key doesn't seem to register in my program that is supposed to catch all key presses and print what they are to the screen. I haven't seen an answer in my searches online. I've seen references to Mod4 being associated with the Windows key, but that's not a proper Tkinter event (so says my error):

_tkinter.TclError: bad event type or keysym "Mod4"

E.g. the following code gets the above error.

textWidget.bind("<Mod4>", self.myFunction)
like image 569
Brōtsyorfuzthrāx Avatar asked Mar 07 '26 14:03

Brōtsyorfuzthrāx


1 Answers

After some digging I found this: https://www.tcl.tk/man/tcl8.6/TkCmd/keysyms.htm These: <Win_L>, <Win_R>, appear to be the correct keys for Windows. Tested in Python 3.4 on Win7.

like image 175
Von Pittman Avatar answered Mar 09 '26 04:03

Von Pittman