Reputation: 5439
I am trying to use a simple event listener.
This is what I have so far:
import keyboard
while True:
if keyboard.is_pressed('p'):
print('You pressed P')
I get the error:
AttributeError: module 'keyboard' has no attribute 'is_pressed'
When I check the documentation, I see that is_pressed
exists.
Is there something wrong with the library or am I doing something wrong?
Upvotes: 0
Views: 5043
Reputation: 11714
I'll add it as a formal answer anyways. You mentioned that you git clone
the repository. I guess this is confusing since the README says you can either do pip install
or git clone
to install the package.
When you do import
, it tells Python to go through its package manager to find the module and these need to be installed on your end. pip
is the package management system that Python uses
If you want to install a package that you have as a local folder (i.e. if you wanted to test a local module) you can do so see here
Upvotes: 2
Reputation: 31
please try to rename your document. don't put name as "keyboard.py"
Upvotes: 1