Keyboard Shortcuts
Demonstrates how to create keyboard shortcuts for htmx enabled elements
from fasthtml.common import Button, fast_app
app, rt = fast_app()
# <button class="btn primary" hx-trigger="click, keyup[altKey&&shiftKey&&key=='D'] from:body"
# hx-post="/doit">Do It! (alt-shift-D)</button>
@app.get
def page():
return Button("Do It! (shift-D)", hx_trigger="click, keyup[shiftKey&&key=='D'] from:body", hx_post="/doit")
@app.post
def doit():
return "You did it!"