Untitled
unknown
python
10 months ago
581 B
6
Indexable
from gpiozero import Button
from signal import pause
from time import time
button = Button(17)
last_press_time = 0
isPressed = False
double_click_threshold = 0.5
def check_double_click():
global last_press_time
global isPressed
if isPressed:
return
isPressed = True
current_time = time()
time_difference = current_time - last_press_time
if time_difference <= double_click_threshold:
print("Çift tıklama algılandı!")
else:
print("Tek tıklama.")
isPressed = False
last_press_time = current_time
button.when_pressed = check_double_click
pause()
Editor is loading...
Leave a Comment