Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

As a student, I want a key_held() alias for keys_held() #64

Open
5 of 7 tasks
AlphaRLee opened this issue Nov 10, 2020 · 3 comments · Fixed by #74
Open
5 of 7 tasks

As a student, I want a key_held() alias for keys_held() #64

AlphaRLee opened this issue Nov 10, 2020 · 3 comments · Fixed by #74
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@AlphaRLee
Copy link
Member

AlphaRLee commented Nov 10, 2020

Currently we have keys_held(), but the most popular use case would be for just a single key

AC:

  • Add a key_held(str, pattern=None) with the @ignite_global, where str is a string representing if a single key is held down.
    • If pattern is None, then check if the key is held.
    • If pattern is a boolean, then check that the key matches the boolean state (True means key is held, False means key is not held).
    • Return a boolean indicating if the key is held or not
    • Add validation for a single string and an optional pattern=boolean (validating the pattern param is low priority)
  • Add a unit test
  • Update docs
@AlphaRLee AlphaRLee added documentation Improvements or additions to documentation enhancement New feature or request labels Nov 10, 2020
@AlphaRLee AlphaRLee added this to the Week 5 milestone Nov 10, 2020
@AlphaRLee AlphaRLee changed the title Add key_held() alias As a student, I want a key_held() alias for keys_held() Nov 10, 2020
@lawruble13 lawruble13 self-assigned this Nov 10, 2020
@lawruble13
Copy link
Contributor

Personally, I don't think this is a particularly useful addition, because

  • for the presumed most popular use case it's a single additional character (i.e. keys_held('a') vs key_held('a'));
  • the conceptual difficulty of the method as-is is almost nil;
  • using the pattern here requires more characters and reduces clarity vs the pythonic way (i.e. key_held('a', False) vs not key_held('a')); and
  • even if we remade key_held to do a more efficient check against the internal dictionary, the performance improvement would almost certainly be countered by the additional load of the validation function

@lawruble13 lawruble13 linked a pull request Nov 12, 2020 that will close this issue
@AlphaRLee
Copy link
Member Author

for the presumed most popular use case it's a single additional character (i.e. keys_held('a') vs key_held('a'));
the conceptual difficulty of the method as-is is almost nil;

I'm not a fan of the lack of clarity (why "keys held" instead of "key held")? I agree it's trivial to handle this either way. Even when you do want to do multiple key presses, it's not often that you want to do key1 AND key2, it's more common for key1 or key2 (e.g. moving a character around), which is usually done in 2 separate if statements

using the pattern here requires more characters and reduces clarity vs the pythonic way (i.e. key_held('a', False) vs not key_held('a'));

I'm ok tossing out this feature, I agree there's not much value in this one.

even if we remade key_held to do a more efficient check against the internal dictionary, the performance improvement would almost certainly be countered by the additional load of the validation function

Tbh, I'm not concerned about efficiency on this check. Correct me if I'm wrong, but I don't see this bogging down performance significantly.

@lawruble13
Copy link
Contributor

Merged PR #74, does not include documentation or unit test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants