Skip to content
Advertisement

Python keyboard module error: TypeError: ‘NoneType’ object is not callable

My code is:

JavaScript

I ran it as root. When I press a key, it prints the key as intended. But, when I press any key right after it, it just returns an error, like this:

JavaScript

and it keeps print out errors like that, don’t matter what key I pressed. Please help.

Advertisement

Answer

not reading the docs be like
The function keyboard.on_press() invokes a callback, not a function. This code shows that:

JavaScript

When you press random keys, it prints out KeyboardEvent(<key> down). The key string can be extracted using keyboard.read_key().

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement