A
A
Arseniy Krutyakov2019-11-17 17:19:37
Python
Arseniy Krutyakov, 2019-11-17 17:19:37

How to make the program continue when one of the keys is pressed?

there is a keyboard module
it has a wait function

spoiler
keyboard.wait("5") - Ждёт нажатия на кнопку - 5

it will stop the program until I press a certain key on the keyboard
but I need to make it so that execution continues when I press either button 5 or 6

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
o5a, 2019-11-17
@o5a

Well, it’s probably worth organizing an endless loop yourself and waiting for any key that you yourself check, for example, like this.

import keyboard

while True:
  print('waiting...')
  key = keyboard.read_key()
  print(key)
  if key in ['5', '6']:
    print('OK')
    break

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question