Description
Anytime I press a key that pynput does not seem to like: ctrl, alt, win, tab, scrLk, shift etc. the listener breaks & returns error: AttributeError: 'Key' object has no attribute 'char'
Platform and pynput version
Windows 10 Pro, pynput 1.7.6
To Reproduce
pynput is located in a subdirectory & is handling the keyboard for a tkinter application, here is some of my code:
On Press:
def on_press(key):
if key.char == (A1_bind):
global active_A1
if active_A1 == 0:
mixer.Channel(0).play(mixer.Sound(A1_sound))
A1.config(bg=pad_active, fg=pad_active)
banklights.itemconfig(bank_a_light, fill=banklight_active)
print("Pad A1 Triggered")
active_A1 = 1]
On Release:
def on_release(key):
if key.char == (A1_bind):
global active_A1
if active_A1 == 1:
if pad_sustain == "False":
mixer.Channel(0).stop()
A1.config(bg=pad, fg=pad)
banklights.itemconfig(bank_a_light, fill=banklight)
active_A1 = 0
else:
A1.config(bg=pad, fg=pad)
banklights.itemconfig(bank_a_light, fill=banklight)
active_A1 = 0
The key parameter passed to listeners is not necessarily a KeyCode instance---please consult the documentation. You cannot expect the argument to have the char attribute.
Description Anytime I press a key that pynput does not seem to like:
ctrl
,alt
,win
,tab
,scrLk
,shift
etc. the listener breaks & returns error:AttributeError: 'Key' object has no attribute 'char'
Platform and pynput version Windows 10 Pro, pynput 1.7.6
To Reproduce pynput is located in a subdirectory & is handling the keyboard for a tkinter application, here is some of my code:
On Press:
On Release:
Keyboard Listener: