dora-robomaster / operators /keybinding_op.py
haixuantao's picture
Initial commit
12d535c
raw
history blame
626 Bytes
import pynput
import pyarrow as pa
from dora import Node
node = Node()
def on_key_release(key):
try:
if key.char == "1":
print("Key 'm' pressed up")
node.send_output("mic_on", pa.array([]))
elif key.char == "2":
print("Key '2' pressed up")
node.send_output("cancel", pa.array([]))
elif key.char == "3":
print("Key '3' pressed up")
node.send_output("failed", pa.array([]))
elif key.char == "0":
exit()
except AttributeError:
pass
pynput.keyboard.Listener(on_release=on_key_release).run()