arnav
arnav

Reputation: 49

what are all the key names in keyboard module?

In the python keyboard module https://pypi.org/project/keyboard/ what are all the names of the keys? can anybody give me a list of it because I can't find one.

Upvotes: 1

Views: 18729

Answers (2)

VonDerHase
VonDerHase

Reputation: 38

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()

Upvotes: 0

user2357112
user2357112

Reputation: 280227

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.

Upvotes: 4

Related Questions