Is there a function called by text_input change, everytime when I input a character?

I know the onchange function for textinput. as you see, following code. st.text only changes when I finish my input and clicked somewhere else. I want st.text change with text_input on time.

import streamlit as st
if "input" not in st.session_state:
    st.session_state.input = ""
def input_callback():
    st.session_state.input = st.session_state.my_input
user_input = st.text_input("input some :", key="my_input",on_change=input_callback,args=None)
st.text("your input is : " + st.session_state.my_input)
st.text("your input is: " + st.session_state.input)

Hi @wocat11

I think you might be interested in the streamlit-keyup Streamlit component created by @blackary that allows output display to dynamically update with each new character.

Here’s a screencast from the above repo:

189153486-7ff7641c-1c76-4fa1-b0d5-f6634f8f0e41

Hope this helps!

Best regards,
Chanin

4 Likes

It works. Thanks very much!!! :grinning:

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