ted_9000
ted_9000

Reputation: 33

How to detect any key press with the keyboard module?

I want to make something so whenever you press any key, it will type something else.

I have tried to make a list of all letters but that didnt work

I want to use this command

while True:
    if keyboard.is_pressed('a')
        print(list(text[1]))

but i want it to work like this

if keyboard.is_pressed('any key')

Upvotes: 3

Views: 1006

Answers (1)

Hass786123
Hass786123

Reputation: 676

Read the doceument that palvarez recommended because the answer is in there.

I have done it here for you:

import keyboard

while True:
    if keyboard.read_hotkey():
        print("you have pressed a key")

Upvotes: 2

Related Questions