SIMEL
SIMEL

Reputation: 8939

How to bind the '+' and '-' keys is Tcl/Tk

How can I bind the + and - keys to commands in Tcl/Tk?

Upvotes: 4

Views: 1593

Answers (1)

fcr
fcr

Reputation: 170

For this particular problem:

set foo "t:"
pack [label .l -textvar foo]
bind . <Key-plus> {append foo "+"}
bind . <Key-KP_Add> {append foo "(+)"}
bind . <Key-minus> {append foo "-"}
bind . <Key-KP_Subtract> {append foo "(-)"}

But in general you can find the key name by running "xev" and pressing that key.

Upvotes: 6

Related Questions