Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python/Tkinter: Getting the full Event name?

How do I get the full name of an event? For example, Event.keysym only shows "c" for an event triggered by "<Control-c>". How can I get the "Control" too?

like image 579
voxeloctree Avatar asked Sep 03 '25 16:09

voxeloctree


1 Answers

Event.state holds the OR'd together states of the modifier keys. So you could try something like:

modifiers = []
if event.state & 1:
    modifiers.append('Shift')
if event.state & 4:
    modifiers.append('Control')
# ... etc
print '-'.join(modifiers)

See here for more details.

like image 133
ekhumoro Avatar answered Sep 05 '25 07:09

ekhumoro