R
R
Resolut2021-11-14 21:11:00
Python
Resolut, 2021-11-14 21:11:00

keyboard input | How to clear the input stream in this case?

There is a menu that I navigate using the keyboard module
61914f709efd8602543424.png
. In this case, to go to the item, you need to press z + x, press and that's what happens.
61914fa00012f703411290.png
"zx" has already been written to the input stream

# Основной файл с хоткеями для передвижения по меню
keyboard.add_hotkey('up', menu.Up)
keyboard.add_hotkey('down', menu.Down)
keyboard.add_hotkey('z+x', menu.GoingToItemMenu)
keyboard.wait()

# Кусок файла с классом Menu
def GoingToItemMenu(self):
        if self.selected == 1:
            keyboard.clear_all_hotkeys()
            logic.Registation()

#Файл logic
Users = []
def Registation():
    login = input("Введите логин: ")
    password = input("Введите пароль: ")

I tried clearing the buffer, setting time.sleep, anyway, when going to the item in the Login field, zx characters appear.
If I had made the transition to the item on enter, the login line would have been skipped altogether.
I would be grateful for your help in this matter!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Karabanov, 2021-11-14
@lxst

This is a feature of Linux: Support for key suppression

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question