Add or expose key press or key down event
-
Describe the Feature Request
I want to use the OTP input field without a form and want a key down or keypress event to track the
Enter Keyso that I can submit the value when the enter key is pressed. - Describe Preferred Solution
...
onKeyDown={keydown}
...
/>```
same here
Same here
workaround: wrap the component in a div and put a keydown handler on that
@ibash that workaround works well. Also, you can do the same thing by putting that component inside a form and listening to the onSubmit event of the form, which is what I did in my project.
Hi, is this issue up for grabs? Then I would like to work on it.
Do it!
Okay, I'll start working on it.
Is the issue still not done? I would like to take it
Use it like this:
<div>
<form onSubmit={handleOtpSubmit}>
<OtpInput
hasErrored={hasErrored}
errorStyle='two-fa-otp-error'
value={otp}
onChange={handleChange}
numInputs={6}
isInputNum={true}
containerStyle='two-fa-otp-input'
shouldAutoFocus
/>
<Button className='d-none' type='submit' />
</form>
</div>
that way, on enter, you will get event in handleOtpSubmit