Skip to content

Instantly share code, notes, and snippets.

@GeeWee
Created November 24, 2017 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GeeWee/2c972c3e04ec461a57d398405ec88d0f to your computer and use it in GitHub Desktop.
Save GeeWee/2c972c3e04ec461a57d398405ec88d0f to your computer and use it in GitHub Desktop.
Example of a dragonfly Grammar
example_grammar = {
# A dragonfly grammar is basically a python dictionary of phrases to the actions they should trigger
# With some special syntax for words than can vary. See the up command below, where "[<n>]" in the key means "any number"
# Then it's possible to use that number in the action. "up:%(n)d" means press the up key n times
# where n was the number from before
"up [<n>]": Key("up:%(n)d"),
# This allows us to go up by an amount. E.g. saying "up two" will simulate pressing the up button two times
"down [<n>]": Key("down:%(n)d"),
"space": release + Key("space"),
# Saying space will release all other held keys, and simulate a space press
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment