62: [FEAT] Create Hook - useKeyPress()#83
Merged
DavidHDev merged 1 commit intoDavidHDev:mainfrom Nov 15, 2024
Merged
Conversation
DavidHDev
reviewed
Nov 5, 2024
DavidHDev
approved these changes
Nov 15, 2024
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.
Description
A hook that detects when a specific key or combination of keys is pressed.
Acceptance Criteria
Details:
['Control', 'Shift', 'X']forCtrl + Shift + X.Setto track keys currently pressed. It compares this set with the target key set to determine if all required keys are pressed.keydownevent adds the pressed key to the set and checks if the required keys are pressed. If all keys are pressed, the callback is triggered.keyupevent removes the key from the set once it is released.blurevent clears the set to avoid lingering key states when the window loses focus.Usage
Arguments:
keys(array of strings):['Control', 'C']forCtrl + C).callback(function):Note: When passing keys, you must use their specific string names as recognized by the
KeyboardEventAPI. For instance: UseEscapeinstead ofEsc.