Version 11 of keysyms

Updated 2003-06-06 18:19:40

http://www.purl.org/tcl/home/man/tcl8.4/TkCmd/keysyms.htm describes what key symbol values can be used with bind (any other commands?).


[What is a key symbol?]


Open a wish session and type

  bind . <KeyPress> {puts %K}

Then press any key or key combination to learn the keysym for your desired key binding


Is there any way to use accented characters (as used in many European languages) in bindings? I want, for example, Alt-e' (meant to be Alt pressed with an accented e) to be bound to a command. -- CLN 2001-06-11

Peter Lewerin 2001-06-30:

 bind . <Alt-Key-eacute> ...

would seem to do what you want, but possibly only if you actually have a é key to press. At least for me, characters composed with dead keys don't fire the bindings, but character keys (e.g. adiaeresis on my keyboard) do.


[Distinguish keysyms and key codes.]


Mo included in the Tk test suite keypress-pertinent code. He advises, "See the following procs in tk/tests/event.test:

_init_keypress_lookup _keypress_lookup _keypress _keypress_string

With these commands you can do the following:

    _keypress_string $w HELLO\n

This will generate a keypress for each letter followed by an event for the return key."


A Tkinter correspondent:

    from Tkinter import *

    class Output(Label):
        def printkey(self, event):
            self.config(text=event.keysym)

    root = Tk()
    label = Label(root, text='Press a key...')
    output = Output(root, takefocus=1)
    label.pack()
    output.pack()
    output.focus()
    output.bind('<KeyPress>', output.printkey)
    root.mainloop()       

Tk syntax help - Arts and crafts of Tcl-Tk programming