Search code examples
python-3.xevdev

How to break out of read_loop() in python-evdev?


I am using read_loop() from python-evdev to capture the codes from an ir remote control.

#!/usr/bin/env python3
from evdev import InputDevice
dev = InputDevice('/dev/input/event0')
for event in dev.read_loop():
    print(event.value)

How can I break out of the loop when the codes from a button are received and the button no longer is pressed?


Solution

  • I reckon read_loop results in an endless loop. If you are looking to read a single input event, read_one would be the better choice.

    Source: Page 25