Не работает нажатие сразу двух клавиш
Когда нажимаешь сразу две клавиши срабатывает только одна функция как это исправит?
import keyboard
import tkinter as tk
import tkinter.ttk as ttk
import time
import os
import sys
temp_1 = 0
after_id_1 = ''
temp_2 = 0
after_id_2 = ''
t = 0
def on_key_event(event):
if event.event_type == keyboard.KEY_DOWN:
if event.name == 'F5':
start_tick_all()
elif event.name == 'F6':
stop_tick_1()
elif event.name == 'F7':
stop_tick_2()
elif event.name == 'F8':
restart()
keyboard.hook(on_key_event)
def tick_2():
global temp_2, after_id_2, f_temp_2, milliseconds
milliseconds = int((time.time() - int(time.time())) ) # Получаем миллисекунды
after_id_2 = root.after(10, tick_2) # Обновляем каждые 10 мс
f_temp_2 = time.strftime("%H:%M:%S", time.gmtime(temp_2)) + f".{milliseconds}" # Добавляем миллисекунды
label_2.configure(text=str(f_temp_2))
temp_2 += 1
def tick_1(): # Запуск и отображение первой кнопки
global temp_1, after_id_1, f_temp_1, milliseconds
milliseconds = int((time.time() - int(time.time())) )
after_id_1 = root.after(10, tick_1)
f_temp_1 = time.strftime("%H:%M:%S", time.gmtime(temp_1)) + f".{milliseconds}"
label_1.configure(text=str(f_temp_1))
temp_1 += 1
def start_tick_all():
tick_1() #Таймер_1 запускается
tick_2()
def stop_tick_1():
root.after_cancel(after_id_1) #Таймер_1 останавливается
def stop_tick_2():
root.after_cancel(after_id_2) #Таймер_1 останавливается
def continue_tick_1():
tick_1() #Таймер_1 возобновляется
def restart():
global temp_1, after_id_1, temp_2, after_id_2
# Останавливаем текущие таймеры
stop_tick_1()
stop_tick_2()
# Сбрасываем значения для таймеров
temp_1 = 0
temp_2 = 0
# Обновляем метки времени
label_1.configure(text='00:00:00')
label_2.configure(text='00:00:00')
root = tk.Tk()
root.title("Welcome")
root.geometry('1200x800')
label_1 = tk.Label(root, text='00:00:00', font=('Arial', 50, 'bold'), fg='red', bg='green')
label_1.place(x=250, y=350)
label_2 = tk.Label(root, text='00:00:00', font=('Arial', 50, 'bold'))
label_2.place(x=600, y=350)
label_3 = tk.Label(root, text='1', font= ('Arial', 50, 'bold'))
label_3.place( x = 360, y =200)
label_4 = tk.Label(root, text='2', font= ('Arial', 50, 'bold'))
label_4.place( x = 710, y =200)
keyboard.add_hotkey("F6",stop_tick_1)
keyboard.add_hotkey('F5', start_tick_all)
keyboard.add_hotkey('F7', stop_tick_2)
keyboard.add_hotkey('F8', restart)
root.mainloop()