On Sat, 26 Mar 2016 17:47:02 +0000, MRAB wrote: > 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.
Works perfectly. > The second is for either "Alt" key plus the "Q" key and Caps Lock turned on. Also works, however, I discovered if I leave out 'Lock' it still works with caps on. It also works with caps off while holding either Shift key and hitting Alt-q. I tested it with Python 2.7 and 3.4. Well at least I can cut the number of lines down to two per binding like this: root.bind("<Alt-q>", quit) root.bind("<Alt-Q>", quit) Once again I am in your debt. Thank you. -- <Wildman> GNU/Linux user #557453 The cow died so I don't need your bull! -- https://mail.python.org/mailman/listinfo/python-list