是否有 turtle-graphics 使用的关键事件名称的完整列表?
Is there a complete list of key event names used by turtle-graphics?
在玩弄 Python's Turtle module, I used some key events 时如官方文档所述:
turtle.onkey(fun, key)
Parameters:
fun
– a function with no arguments or None
key
– a string: key (e.g. “a”) or key-symbol (e.g. “space”)
现在有趣的是,当您调用 1) onkeyrelease()
方法并传递一个未注册的字符串(如空字符串 (""
), 或 "+"
, 等等) 作为 key
参数:
turtle.onkeyrelease(lambda: print("Got key event while listening to none."), "")
无论用户按什么键,程序都会输出“Got key event ...
”,顺便说一下.
中的问题
遗憾的是,我无法在 Internet 上其他地方的文档中找到有关此行为的更多信息。所以我想知道是否有所有支持的 key-name-strings 的完整列表,用于对按键事件进行编程?
1)题中使用的基本设置:
import turtle
turtle.setup(700,500)
turtleWindow = turtle.Screen()
turtleWindow.onkey(lambda: print("You pressed 'a'"), "a")
turtleWindow.listen()
我在 turtle.py
source and came to the same conclusion as , that the keys are part of tkinter
, not turtle
. Not wanting to read through the entire tkinter
source, I did some googling and found this full list of keysyms in the Tk docs, as well as this abbreviated list 中扫描了 Latin-1 键盘(它缺少单个字母,但它们也是有效的键标识符,例如 "Q"
)。我不确定它们是否 case-sensitive,所以你必须做一些实验。
在玩弄 Python's Turtle module, I used some key events 时如官方文档所述:
turtle.onkey(fun, key)
Parameters:
fun
– a function with no arguments or Nonekey
– a string: key (e.g. “a”) or key-symbol (e.g. “space”)
现在有趣的是,当您调用 1) onkeyrelease()
方法并传递一个未注册的字符串(如空字符串 (""
), 或 "+"
, 等等) 作为 key
参数:
turtle.onkeyrelease(lambda: print("Got key event while listening to none."), "")
无论用户按什么键,程序都会输出“Got key event ...
”,顺便说一下
遗憾的是,我无法在 Internet 上其他地方的文档中找到有关此行为的更多信息。所以我想知道是否有所有支持的 key-name-strings 的完整列表,用于对按键事件进行编程?
1)题中使用的基本设置:
import turtle
turtle.setup(700,500)
turtleWindow = turtle.Screen()
turtleWindow.onkey(lambda: print("You pressed 'a'"), "a")
turtleWindow.listen()
我在 turtle.py
source and came to the same conclusion as tkinter
, not turtle
. Not wanting to read through the entire tkinter
source, I did some googling and found this full list of keysyms in the Tk docs, as well as this abbreviated list 中扫描了 Latin-1 键盘(它缺少单个字母,但它们也是有效的键标识符,例如 "Q"
)。我不确定它们是否 case-sensitive,所以你必须做一些实验。