diff --git a/indicators.py b/indicators.py index e2e8c78..0911a66 100644 --- a/indicators.py +++ b/indicators.py @@ -867,15 +867,33 @@ if __name__ == "__main__": ), ] - # start button callback + app.clientside_callback( + """ + function(id) { + document.addEventListener("keyup", function(event) { + if (event.key == ' ') { + document.getElementById('start-button').click() + event.stopPropogation() + } + }); + return window.dash_clientside.no_update + } + """, + Output("start-button", "id"), + Input("start-button", "id") + ) + + # start / stop button callback @callback(Output('interval-component', 'disabled'), Output("start-button", "children"), Output('controls-and-radio-item', 'disabled'), - Input("start-button", "n_clicks"),) + Input("start-button", "n_clicks"), + State("start-button", "children"),) - def start_cycle(n): + def start_cycle(n, value): if n: - if n%2 == 0: + # if n%2 == 0: + if value == "Pause": return True, "Auto Play", False else: return False, "Pause", True