keyboard doesn't have such a list in the docs, or even in the source code. keyboard builds its key information tables at runtime by querying key information from Windows APIs or from dumpkeys, then applying a bit of its own postprocessing.
The key information tables keyboard builds aren't anywhere in its public API, but if you import keyboard, the private keyboard._os_keyboard.from_name table should have all of keyboard's canonical key names. keyboard._canonical_names.canonical_names should have the mapping from non-canonical names to canonical names, if you want that info too, but I'm not sure everything in that table is actually guaranteed to be a supported key.
I want to make a keylogger and learn more about the keyboard module. PyPI has a doc for it but I doesn't go in depth on what methods to input and what they mean.
I found the python standard library but the doc is not there
https://docs.python.org/3/library/index.html
I wanted to know where can I find the doc for it or where can I learn about the keyboard library?
It looks like the module takes Windows keys, will the keyboard library work with Mac as well and can I use the same key inputs when coding?
Also, I am beginner in python will a Keylogger be a good beginner project?
python - what are all the key names in keyboard module? - Stack Overflow
Installing keyboard module blues
How to detect keypress in python using keyboard module? - Stack Overflow
Using keyboard in my program
Videos
» pip install keyboard
keyboard doesn't have such a list in the docs, or even in the source code. keyboard builds its key information tables at runtime by querying key information from Windows APIs or from dumpkeys, then applying a bit of its own postprocessing.
The key information tables keyboard builds aren't anywhere in its public API, but if you import keyboard, the private keyboard._os_keyboard.from_name table should have all of keyboard's canonical key names. keyboard._canonical_names.canonical_names should have the mapping from non-canonical names to canonical names, if you want that info too, but I'm not sure everything in that table is actually guaranteed to be a supported key.
Well, if you are curious about some keys, you can just run:
import keyboard
def test(callback):
print(callback.name)
keyboard.hook(test)
keyboard.wait()
First of all, you forgot to close the strings on lines 4 and 6.
But your main issue is that you call keyboard.read_key() once for each arm of your if statement. This makes your code wait for a keypress, check if it's 'enter', then wait for another keypress, check if it's 'q', and so on.
What you should do is save the key to a variable, then check the variable. It should look something like this:
import keyboard
while True:
key = keyboard.read_key()
if key == 'enter':
print('Enter is pressed')
if key == 'q':
print('Quitting the program')
break
if key == 's':
print('Skiping the things')
As per Keyboard documentation:
Other applications, such as some games, may register hooks that swallow all key events. In this case keyboard will be unable to report events.
One way to solve your problem with keyboard module is keyboard.wait('key')
# Blocks until you press esc
keyboard.wait('esc')
Something work around is as below:
import keyboard
keyboard.wait('enter')
print('Enter is pressed')
keyboard.wait('q')
print('Quitting the program')
keyboard.wait('s')
print('Skiping the things')