I have a Raspberry Pi and an RFID scanner running a python script. I'm using tkinter to capture input using the following code.
from Tkinter import *
import Tkinter as tk
def __init__(self):
command = tk.Tk()
self.e = Entry(command)
self.e.grid()
self.e.focus_set()
command.bind('<KeyPress>', self.key_input)
command.mainloop()
def key_input(self, event):
key_press = event.keysym
if key_press == 'Return':
time.sleep(0.5)
self.enter()
else:
pass
def enter(self):
//various API calls etc. Here is where the RFID tag is often duplicated)
I'm getting some weird behaviour where the RFID tag is captured twice before a return is fired and I'm wondering if it is because of the order of operations.
Would binding using < keypress> vs < keyrelease> change anything? Or not because it's an RFID scanning and not a user pressing keys? Would using the < Return> be preferential? Or is the above code accomplishing the same thing?