Add support for enter key/submit in Input component #2831
-
Currently the Possible solution
https://ant.design/components/input/ Good Day |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
We rely heavily on native web platform conventions. As such, the things you are trying to achieve can be done as if you were just using HTML on its own. To respond to an enter key press inside a form control, you should use some of the To respond to a form submission, you should use a form element to wrap your form, and respond to the I've created a Codesandbox to demonstrate how this works https://codesandbox.io/s/form-events-and-submission-example-e33kbf |
Beta Was this translation helpful? Give feedback.
Hi @pranshuchittora
We rely heavily on native web platform conventions. As such, the things you are trying to achieve can be done as if you were just using HTML on its own.
To respond to an enter key press inside a form control, you should use some of the
keyPress
orkeyDown
events that are support by the HTML Input element.To respond to a form submission, you should use a form element to wrap your form, and respond to the
onSubmit
form event.I've created a Codesandbox to demonstrate how this works
https://codesandbox.io/s/form-events-and-submission-example-e33kbf