Enter key press to submit st.form

Hi again (starting to feel like a local here! got too many annoying questions :upside_down_face:),

Just wondering why pressing the enter/return key in a Streamlit form doesn’t automatically submit the form. I’ve done some tests and pressing enter on a text_input in a form doesn’t seem to trigger a re-run of the script so it seems it’s not being used for that.

Could it be that it’s because the <form> tags are omitted in the rendered html?
It would be epic if the input widget that currently has focus is seen as part of that specific form and the corresponding submit button so that it’s possible to have multiple forms too that won’t get in the way with the enter key press since it will just grab the submit button that’s part of that form where the focus is at.

There’s a good case to be made for accessibility too!
(The Enter Key should Submit Forms, Stop Suppressing it)

Thanks and have an awesome Streamlitty-bitty day! :sun_with_face:

1 Like

Hey @Fhireman!

You’re correct that we don’t use the <form> tag in the rendered HTML, and we don’t currently support enter-to-submit - and we should! I’ve added a feature request here:

4 Likes

Thanks for opening up the feature request :slight_smile:

1 Like

Would love what seems like an essential for forms to become a reality with registering Enter to submit. Thanks for raising this @Fhireman

1 Like

No problemo!
Hope it gets added fast :slight_smile:
Just those quality of life improvements that make it more awesome to use

Any updates on this? Id love this feature as well.

Particularly because I am trying to get a text input to clear after entering

Yes, that functionality is in the brand new release, actually! @jaycoolslm

Update your version of Streamlit to >=1.25.0. :balloon:

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.