Skip to content

[test]: useKeyboard#449

Open
forckes wants to merge 1 commit intosiberiacancode:mainfrom
forckes:test/useKeyboard
Open

[test]: useKeyboard#449
forckes wants to merge 1 commit intosiberiacancode:mainfrom
forckes:test/useKeyboard

Conversation

@forckes
Copy link
Contributor

@forckes forckes commented Mar 14, 2026

In useKeyboard hook useRefState(window) called unconditionally crashing on SSR since window is undefined. So i added initial value
Also added UseKeyboardReturn type for tests.

Tests:
Added useKeyboard.test.ts that checks all 6 target variants and verifies:

  • the hook return value (on client and on server)
  • that the callback runs on keydown
  • that onKeyDown option works
  • that onKeyUp option works
  • that both onKeyDown and onKeyUp work together
  • that event listeners are removed on unmount
  • that the correct keyboard key is passed to the callback
  • that the listener attaches to window when no target is provided
  • that updated options work after rerender

Fixes #373

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont know why bundle file was added here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[test]: Test for useKeyboard

1 participant