Key-press names

Frequently people ask 'what is the value I give to bind for the KKK key' (where KKK is replaced by things like space, tab, etc.)

Here's a line of Tk which will display the names that bind accepts; just press the key and it writes (to stdout) the phrase. Of course, on MacOS or Windows you have to ensure you have a console for the stdout to be displayed (see "How to ensure my Windows or MacOS Tk process has a console").

  bind . <Key> {puts "You pressed the key called \"%K\""}

See also KeySyms on platforms other than X11.