Skip to content

Question: How to waif for key event? #155

Description

@dennyh

How would I get my script to wait for one of two key presses in mpv?
I want to wait for the user to press one of two keys and then do things based on what key was pressed.

Currently I have hacked together a an ugly way of waiting for keypresses using wait_for_event and on_key_press sending some text to the osd.

# send client-message
@player.on_key_press("ENTER")
	def my_ENTER_binding():
		player.show_text("text")
# waiting for key press
player.wait_for_event("CLIENT_MESSAGE", cond=lambda evt : evt["event"]["args"][2:4] == ["d-", "ENTER"])

You might be able to tell I am fairly new to python.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions