I'm coding a program that sends some data via serial when a key is pressed:
Python code:
from Tkinter import *
from serial import Serial
Arduino = Serial(3)
Arduino.baudrate = 115200
root = Tk()
def Acelerate (event):
Arduino.write ("Ax")
def Reverse (event):
Arduino.write ("Rx")
def Right (event):
Arduino.write ("xD")
def Left (event):
Arduino.write ("xE")
root.bind ('<Up>', Acelerate)
root.bind ('<Down>', Reverse)
root.bind ('<Right>', Right)
root.bind ('<Left>', Left)
root.mainloop()
It's working pretty fine. You press Up in you keyboard, it sends data which makes an RC car move forward. You press Down, it moves backward. When you press Right or Left, it turns its wheels to that side.
Now I need to do this: when I press, for example, Up and Right at the same time, I need to send "AD" (stupid math, "Ax + xD"), and analog for other combinations.
How can I do this multi-key binding?
I saw some examples with modifier keys, like "root.bind ('<Control-A>', asd)", but this combination <'Key1-Key2'> seems to work only with these modifiers (Control, Alt, Shift, etc).
So, do you think it's possible?