Skip to main content

Streamlit keyboard shortcuts for your buttons.

Project description

Streamlit Shortcuts

Streamlit Shortcuts allows you to easily add keyboard shortcuts to your Streamlit buttons.

Installation

pip install streamlit-shortcuts

Example

⭐ NEW! thanks to @quantum-ernest

import streamlit as st
import streamlit_shortcuts

def delete_callback():
    st.write("DELETED!")

streamlit_shortcuts.button("delete", on_click=delete_callback, shortcut="Ctrl+Shift+X")

🥱 Old

import streamlit as st
from streamlit_shortcuts import add_keyboard_shortcuts

def delete_callback():
    st.write("DELETED!")

st.button("delete", on_click=delete_callback)

add_keyboard_shortcuts({
    'Ctrl+Shift+X': 'delete',
})

The 'Ctrl+Shift+X' combination will trigger "Another Button".

Keys

  • Modifiers: 'Ctrl', 'Shift', 'Alt', 'Meta' ('Cmd' on Mac or 'Win' on Windows, thanks to @toolittlecakes)
  • Common Keys: 'Enter', 'Escape', 'Space'
  • Arrow Keys: 'ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'

Examples of Key Combinations:

  • 'Ctrl+Enter'
  • 'Shift+ArrowUp'
  • 'Alt+Space'

For a complete list of key values, refer to: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values

Contributing

Contributions are welcome! If you have suggestions for improvements or bug fixes, please feel free to make a pull request or open an issue.

Contributors

@toolittlecakes - Added 'Meta' modifier

@quantum-ernest - Improved usage ergonomics

@taylor-ennen - Fixed usage flow of code

Credits

Solution seen on: https://github.com/streamlit/streamlit/issues/1291

https://gist.github.com/brunomsantiago/e0ab366fc0dbc092c1a5946b30caa9a0

@brunomsantiago

@TomJohnH

And wrapped for comfier usage.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit-shortcuts-0.1.4.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

streamlit_shortcuts-0.1.4-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file streamlit-shortcuts-0.1.4.tar.gz.

File metadata

  • Download URL: streamlit-shortcuts-0.1.4.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for streamlit-shortcuts-0.1.4.tar.gz
Algorithm Hash digest
SHA256 140ffdc1f5dccf400ae4793ab25b6754788317a923e5505fed3d92d3dd155b71
MD5 4b9c7ee5f730db3490cbda0c04f6a1ac
BLAKE2b-256 d6dc637a46a0c981f77404f77353656a8024b9c08a53bfc129f098067359efad

See more details on using hashes here.

File details

Details for the file streamlit_shortcuts-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_shortcuts-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 286945a6c1fd462bbbecf620534898c1c4b04dce99ac94c168712ae6842ab0ba
MD5 e96202a14c6de477e439b29f3cc0a0f9
BLAKE2b-256 b26ee5ef05fe23842f61a70010a35168d1806f0a5e98a8462feb55447d8c376b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page