Python keycode actions

Hello, I am trying to set some actions by keycodes with Python: for example, let an iteam speak when key “q” is pressed. Any hints on that? I have already tried with the code input.on_key_down(item_name, key_code=“q”), and the same with key_up and key_pressed, but nothing seems to work.

This part of the Python code is working perfectly.
#example functions:
def zdance():
zebra.animation.play_looping(“Dance”)
def zsleep():
zebra.animation.play_looping(“Sleep”)
def zwalk():
zebra.animation.play_looping(“Walk”)

#example code:
input.on_key_pressed(zdance,“d”)
input.on_key_down(zsleep,“s”)
input.on_key_up(zwalk,“w”)

More examples in Basics Python 7.
First there has to be a function in the pretences and then the key of choice (space, right_mouse_button,d,s,w …)
Have fun coding!

1 Like