0

My code:

from tkinter import *
import tkinter as tk

root = Tk()

def Hello():
    print("You press '<' key")

root.bind("<", Hello)
root.mainloop()

But I receive error:

_tkinter.TclError: no event type or button # or keysym

I tried "<<>" and "Shift-," but it does not work.

hc_dev
  • 8,389
  • 1
  • 26
  • 38
Block
  • 159
  • 1
  • 6
  • is "less than" `` what you're looking for? – Hampus Larsson Aug 22 '21 at 12:26
  • Does this answer your question? [List of All Tkinter Events](https://stackoverflow.com/questions/32289175/list-of-all-tkinter-events) – Tomerikoo Aug 22 '21 at 13:31
  • Probably you could clarify in words or images which key you want to bind (e.g. _less-than_ which is same as _open angle-bracket_ as opposed to _left-arrow_). Different interpretations already lead to discussion. – hc_dev Aug 22 '21 at 13:42

1 Answers1

4

What you're looking for is this:

root.bind("<less>", Hello)

You can find a compete list of Key-Synonyms in the original documentation of Tk.

Hampus Larsson
  • 3,050
  • 2
  • 14
  • 20