To map our keyboard inputs we can use a python module called Tkinter.
Tkinter is Python’s de-facto standard GUI (Graphical User Interface) package. Tkinter is not the only GUI Programming toolkit of Python, however, it is the most commonly used one.
Start by importing the library and setting up the window.
import Tkinter as tk
window = tk.Tk()
#set the size of the window
#start the loop
Creating a Label
Everything from now on needs to go before the mainloop(). We are going to create a label which will sit in the window and display the keys which are pressed.
lblStroke = tk.Label(window, text="Button Press")
Now we have our window setup we need to create a key press event handler.
x = event.char
if x == "q":
#bind all major keys and call our keypress handler
This is a very basic introduction on how you could map your keyboard to control your robot using the W,D,S,A keys.