These functions check whether a key has been pressed alone.#4328
Open
rustbasic wants to merge 38 commits intoemilk:mainfrom
Open
These functions check whether a key has been pressed alone.#4328rustbasic wants to merge 38 commits intoemilk:mainfrom
rustbasic wants to merge 38 commits intoemilk:mainfrom
Conversation
typo
bircni
suggested changes
Aug 2, 2024
|
|
||
| /// Was only the given key pressed this frame, with no modifiers? | ||
| pub fn key_pressed_only(&self, desired_key: Key) -> bool { | ||
| self.num_presses(desired_key) > 0 && self.modifiers_not_pressed() |
Contributor
There was a problem hiding this comment.
if one day key_pressed might be modified -we could easily forget this - fix this using the function here, too
pub fn key_pressed_only(&self, desired_key: Key) -> bool {
key_pressed(desired_key) && self.modifiers_not_pressed()
}| } | ||
|
|
||
| /// Is the given key currently held down and no other keys are held down, including modifier keys? | ||
| pub fn key_down_exclusive(&self, desired_key: Key) -> bool { |
Contributor
There was a problem hiding this comment.
Same as above:
pub fn key_down_exclusive(&self, desired_key: Key) -> bool {
key_down(desired_key) && self.keys_down.len() == 1
}| } | ||
|
|
||
| /// Is the given key currently held down and no other keys are held down? | ||
| pub fn key_down_only(&self, desired_key: Key) -> bool { |
Contributor
There was a problem hiding this comment.
As mentioned above:
pub fn key_down_only(&self, desired_key: Key) -> bool {
key_down(desired_key) && self.modifiers_not_pressed()
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These functions check whether a key has been pressed alone.
Add Functions :
modifiers_not_pressed()
key_pressed_only()
key_down_only()
key_down_exclusive()
For Test Code :