imbhargav5 / rooks

Essential React custom hooks ⚓ to super charge your components!
https://rooks.vercel.app
MIT License
3.2k stars 215 forks source link

eventType #1737

Closed electroheadfx closed 6 months ago

electroheadfx commented 10 months ago

I have not success with event type, how is it work ?

https://codesandbox.io/p/sandbox/jolly-zhukovsky-t8g32p?layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clr36mte300063b6f0qkas5th%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clr36mte300023b6fnsxx2vwd%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clr36mte300033b6fwds12j0u%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clr36mte300053b6fa2vdqzo4%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clr36mte300023b6fnsxx2vwd%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clr36mte300013b6fzso5gryl%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Findex.js%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522id%2522%253A%2522clr36nk6j004k3b6fvlv4poag%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522initialSelections%2522%253A%255B%257B%2522startLineNumber%2522%253A7%252C%2522startColumn%2522%253A44%252C%2522endLineNumber%2522%253A7%252C%2522endColumn%2522%253A44%257D%255D%252C%2522filepath%2522%253A%2522%252FApp.js%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%252C%2522id%2522%253A%2522clr36mte300023b6fnsxx2vwd%2522%252C%2522activeTabId%2522%253A%2522clr36nk6j004k3b6fvlv4poag%2522%257D%252C%2522clr36mte300053b6fa2vdqzo4%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clr36mte300043b6fg0m9buul%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522UNASSIGNED_PORT%2522%252C%2522port%2522%253A0%252C%2522path%2522%253A%2522%252F%2522%257D%255D%252C%2522id%2522%253A%2522clr36mte300053b6fa2vdqzo4%2522%252C%2522activeTabId%2522%253A%2522clr36mte300043b6fg0m9buul%2522%257D%252C%2522clr36mte300033b6fwds12j0u%2522%253A%257B%2522tabs%2522%253A%255B%255D%252C%2522id%2522%253A%2522clr36mte300033b6fwds12j0u%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D

gmahima commented 9 months ago

Hi @electroheadfx , this hook is designed to listen for your key press and execute a callback when it's pressed. It appears to be functioning as intended in your sandbox link as well. Could you elaborate on the issue you're encountering?

electroheadfx commented 9 months ago

yeah it seam it works now, I can't remember what happened. Thanks

gmahima commented 9 months ago

Oh ok. By the way, I just realized that you might have been referring to the options object in which you were passing eventTypes: "keyPress", I did not notice it at first since it was commented. I uncommented it and saw that it was indeed not working! Turns out, we need to use a lowercase "p". i.e. keypress. so, the following would work. Hope this helps :)

    {
      eventTypes: "keypress",
    }
electroheadfx commented 9 months ago

hmm ok, I re-tested, sandbox is very buggy its difficult to update the preview. I will test in local, thanks for the tips, I will re-open the ticket if still an issue.

gmahima commented 9 months ago

hmm ok, I re-tested, sandbox is very buggy its difficult to update the preview. I will test in local, thanks for the tips, I will re-open the ticket if still an issue.

Ok, let me know if the fix works or if there's some other issue

stale[bot] commented 7 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.