Idea: Keyboard Bindings

Would anyone be interested in being able to register keyboard events? I’m trying to invent the workflow/syntax. This example is the best I could come up with.

picture = next(picture_generator)

image_holder = st.image(picture)  
keyboard_holder = st.empty()

while True:  
    k = keyboard_holder.key_event()

    if k is not None:  
      if k is "kb_space":  
         picture = next(picture_generator)  
      if k is "kb_esc":  


maybe to keep in line with how st objects are typically rendered on the screen. We might have an interactive keyboard displaying what keys are pressed down/toggled

1 Like

Hi @conic,
thanks for your question. Do you want to file a Feature Request for this?

I think it makes sense to me. I wonder this could be part of core Streamlit or being a “Plugin” (when we will have a Plugin architecture)


I just created a feature request here :