inputs.ButtonState

class inputs.ButtonState(value)

Represents the two states a button can be in at any time.

from inputs import *

input_stream_x = Input.stream("x")

while True:
    for event in input_stream_x:
        if event == ButtonState.DOWN:
            print("pressed x")
        elif event == ButtonState.UP:
            print("released x")

Because the enum values are boolean, it’s not necessary to compare to an enum instance. Instead one can simply case on the value of the state as demonstrated below.

from inputs import *

input_stream_x = Input.stream("x")

while True:
    for event in input_stream_x:
        if event:
            print("pressed x")
        else:
            print("released x")
UP = False
DOWN = True