voxeloctree
voxeloctree

Reputation: 849

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?

Upvotes: 4

Views: 486

Answers (1)

ekhumoro
ekhumoro

Reputation: 120608

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.

Upvotes: 3

Related Questions