问题
I have a bind event for when a key is pressed to trigger a function but how would I see if the key pressed was the enter key? Here is my code:
This did not work. What would I replace the word enter with to check if the enter key is pressed:
def record(self,event):
x = event.char
if x == "Enter":
print("Enter")
回答1:
You can check using keysym:
if event.keysym == 'Return'
来源:https://stackoverflow.com/questions/24671105/how-to-check-if-the-enter-key-is-pressed-python