Skip to content

Instantly share code, notes, and snippets.

Last active June 16, 2023 07:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Flying Flappy Bird with arrow keys
"""fly() and dip() functions are called whenever the up arrow key is pressed or released respectively."""
def key_press(self, key):
"""Listen for key press."""
if key == Key.up:
return False
def key_release(self, _):
"""Listen for key release."""
return False
def keyboard_update(self, _):
"""ROS Timer Callback Keyboard Listener for a press and release."""
with keyboard.Listener(on_press=self.key_press) as listener_for_key_press:
with keyboard.Listener(on_release=self.key_release) as listener_for_key_release:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment