Another Key Binding Question

MRAB python at mrabarnett.plus.com
Sat Mar 26 13:47:02 EDT 2016


On 2016-03-26 17:10, Wildman via Python-list wrote:
> I use some key bindings in my program.  They are declared
> like this:
>
>          root.bind("<Alt_L>" + "q", quit)
>          root.bind("<Alt_R>" + "q", quit)
>          root.bind("<Alt_L>" + "Q", quit)
>          root.bind("<Alt_R>" + "Q", quit)
>
> The above binds both Alt keys with upper and lower case 'q'.
> Is there a way to combine the statements above into one
> statement?
>
Try this:

     root.bind("<Alt-q>", quit)
     root.bind("<Alt-Lock-Q>", quit)

The first is for either "Alt" key plus the "Q" key and Caps Lock turned off.

The second is for either "Alt" key plus the "Q" key and Caps Lock turned on.




More information about the Python-list mailing list