label .l pack .l bind . <KeyPress> {.l configure -text %K}For each key in turn, the label says:
- control == Control_L
- alt == Meta_L
- ⌘ == Alt_L
label .m pack .m bind . <Command-g> {.m configure -text "command g"} bind . <Option-g> {.m configure -text "alt g"} bind . <Control-g> {.m configure -text "control g"}As a final note, it is useful to know that the bindings are case-sensitive; in other words, <Command-g> and <Command-G> are separate bindings, the latter perhaps more easily being understood as Command and Shift and g together.As a postscript, it is unfortunate that whilst Windows uses the Control key as a modifier for the most common operations, e.g. Ctrl-C, Ctrl-X and Ctrl-V for copy, cut and paste respectively, MacOS X uses the ⌘ (command) key in the same situations. Thus it is necessary for a cross-platform application that wishes to adhere to native conventions to define platform dependent bindings.-- Alastair Davies 2005/07/25
JH: I simply manage this with code like:
if {[tk windowingsystem] eq "aqua"} { set control "Command" set ctrl "Command-" } elseif {[tk windowingsystem] eq "win32"} { set control "Control" set ctrl "Ctrl+" } else { set control "Control" set ctrl "Ctrl-" } $menu add command -label "Do Something" -accelerator "${ctrl}d" bind $something <${control}d> { # do something ... }