Streamlit Keyup Input

0.3.0 · active · verified Wed Apr 15

Streamlit-keyup is a custom component for Streamlit applications that provides a text input field which updates its value in real-time, on every key press (on keyup event). This differs from Streamlit's native `st.text_input` which typically waits for the user to press Enter or for the widget to lose focus. The library is currently at version 0.3.0 and receives occasional updates, primarily for compatibility and minor fixes.

Warnings

Install

Imports

Quickstart

This example demonstrates the basic usage of `st_keyup`, including setting a default value, using the `debounce` parameter to control update frequency, and combining `max_chars`, `placeholder`, and `disabled` arguments.

import streamlit as st
from st_keyup import st_keyup

st.title("Streamlit Keyup Demo")

# Basic usage: value updates after every key press
value_basic = st_keyup("Enter text here", key="keyup_basic")
st.write(f"Basic Input: {value_basic}")

# Usage with a default value
value_with_default = st_keyup("Enter with default", value="Hello world", key="keyup_default")
st.write(f"Input with default: {value_with_default}")

# Usage with debounce to limit update frequency (e.g., update every 500ms)
value_debounced = st_keyup("Enter with debounce", debounce=500, key="keyup_debounced")
st.write(f"Debounced Input: {value_debounced}")

# Example with max_chars, placeholder, and disabled
value_complex = st_keyup(
    "Limited and Placeholder",
    max_chars=10,
    placeholder="Max 10 chars",
    disabled=False, # Use os.environ.get for dynamic disable
    key="keyup_complex"
)
st.write(f"Complex Input: {value_complex}")

view raw JSON →