Skip to content

Commit

Permalink
Merge pull request #74 from lawruble13/key_held
Browse files Browse the repository at this point in the history
Add key_held method
  • Loading branch information
lawruble13 authored Nov 24, 2020
2 parents aa1dd0a + 86de094 commit 8008de0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions spark/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,10 @@ def key_repeated(self): pass
# From .util.helper_functions.keyboard_functions

@extern
def keys_held(self, *args):
pass
def keys_held(self, *args): pass

@extern
def key_held(self, *args): pass

# From .util.helper_functions.canvas_functions

Expand Down
8 changes: 8 additions & 0 deletions spark/util/helper_functions/keyboard_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,11 @@ def helper_keys_held(self: Core, *keys, pattern=None):
pattern = [True]*len(keys)
match = [self._keys_held.get(key, False) == want for key, want in zip(keys, pattern)]
return reduce(and_, match)


@validate_args([str], [str, bool])
@ignite_global
def helper_key_held(self: Core, *args):
if len(args) == 1:
args.append(True)
return self.keys_held(args[0], pattern=[args[1]])

0 comments on commit 8008de0

Please sign in to comment.