Loading homepage
Implement a React hook that reports whether a particular keyboard key is currently held down, including resetting the state when the window loses focus.
The JavaScript and TypeScript variants share the same contract. Tests render real React components and exercise updates and lifecycle cleanup.
Input: useKeyPress("Escape") before events Output: Returns false.
Input: keydown with key "Escape", then keyup with key "Escape" Output: Returns true and then false.
Input: Hold "a", then change targetKey to "b" Output: Resets to false and waits for a new keydown with key "b".
Examples describe the current return value after the corresponding React render or event.