Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bind to Control-KeyPress

31 views
Skip to first unread message

Alexandru

unread,
Apr 9, 2019, 5:10:11 PM4/9/19
to
Hi,

Is there reason why the binding to KeyRelease works while to KeyPress it does not?

bind . <Control-KeyRelease> {puts release} ;# Works
bind . <Control-KeyPress> {puts press} ;# Does not work

Thanks!
Alexandru

Alexandru

unread,
Apr 9, 2019, 5:16:03 PM4/9/19
to
Looks like I need to bind <Control_L> instead of <Control-KeyPress>

Andreas Leitgeb

unread,
Apr 11, 2019, 2:06:45 PM4/11/19
to
Alexandru <alexandr...@meshparts.de> wrote:
> Am Dienstag, 9. April 2019 23:10:11 UTC+2 schrieb Alexandru:
>> Hi,
>> Is there reason why the binding to KeyRelease works while to KeyPress it does not?
>> bind . <Control-KeyRelease> {puts release} ;# Works
>> bind . <Control-KeyPress> {puts press} ;# Does not work
> Looks like I need to bind <Control_L> instead of <Control-KeyPress>

Not sure I see the same symptom.

If I press Ctrl-A on the tk window, I do see a press and release for the "a"
plus an extra release for releasing the Ctrl-key itself.

So, if you meant watching the Ctrl-Key itself, then be reminded, that
Control before the dash is a modifier, that means that "some key action
happens, while Ctrl is already pressed". This is not the case while
you press Ctrl itself, but it is while you release it.

In the other case you check for the left Control key itself, so you
get the events on when it is used, not just when it is held while
another key is used.

PS: you might also want to bind for Control_R, or only one of the Ctrl
keys will work :)

Alexandru

unread,
Apr 11, 2019, 2:19:02 PM4/11/19
to
This must be the reason! Good point.

>
> PS: you might also want to bind for Control_R, or only one of the Ctrl
> keys will work :)

Yes, of course I bind to Control_R too.

Thanks for the help!

Regards
Alexandru
0 new messages