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:

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:

2 Likes

Thanks for opening up the feature request :slight_smile:

1 Like