None of the other stackoverflow suggestions, nor any other outside documentation has shown me how to successfully bind a key to a function. Below are links I've tried (code copied and pasted) and had no luck with. I see many people suggesting focus as a reason for failure, as though the frame containing the button isn't the user's target and therefore isn't active; nothing has come from this however. Below are links I have tried:
http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm
python tkinter how to bind key to a button
http://www.java2s.com/Code/Python/GUI-Tk/SetButtontogetfocus.htm
How to bind a keypress to a button in Tkinter
I am running Python 3.6 in PyCharm 5.0.4.
The code in the links above are what I've been using/modifying to see how it works but not a single attempt has ended with an action being carried out. The furthest I've gotten is an error message.
Thanks.
EDIT: code I am using below (from most recent link)
from tkinter import *
root = Tk()
def LeftTurn(event):
print('left')
frame=Frame(root, width=100, height=100)
frame.bind("<Left>", LeftTurn) #Binds the "left" key to the frame and exexutes yourFunction if "left" key was pressed
frame.pack()
root.geometry("640x480")
root.title("Rover ")
root.mainloop()
I also tried this one (below)
from tkinter import *
root = Tk()
def yourFunction(event):
print('left')
frame = Frame(root, width=100, height=100)
frame.bind("<Left>",yourFunction) #Binds the "left" key to the frame and exexutes yourFunction if "left" key was pressed
frame.pack()
root.mainloop()