Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enter key event not triggering #43

Closed
iamrakhmatov opened this issue Nov 10, 2024 · 2 comments · Fixed by #44
Closed

Enter key event not triggering #43

iamrakhmatov opened this issue Nov 10, 2024 · 2 comments · Fixed by #44

Comments

@iamrakhmatov
Copy link

When pressing Enter key onKeyDown event is not triggering, I need this event because I want to change behavior for Enter key, right now when it's clicked focus just moves to the next segment, but I want to propagate the event to parent component and blur the component

@dan-lee
Copy link
Owner

dan-lee commented Nov 11, 2024

So basically you want to have

<input onKeyDown={(e) => { e.target.blur(); }} />

Do I understand that correctly? I guess it has to do with this library calling preventDefault, but not too sure yet. Would need to investigate

@dan-lee
Copy link
Owner

dan-lee commented Nov 12, 2024

You should be able to do so now in https://github.com/dan-lee/timescape/releases/tag/[email protected], but you need to use onKeyDownCapture for it to work:

<input
  onKeyDownCapture={(e) => {
    if (e.key === 'Enter') {
      e.preventDefault()
    }
  }}
/>

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 a pull request may close this issue.

2 participants