Is it possible to access the data stored in dcc.Store from javascript

In my code, when i press certain key from keyboard it has to get value stored in dcc.Store and change it. Since dash does not support natively keyboard event that is why i have to use js event to capture the keyboard event. but there also i have to access the dcc.Store value. How can i access it from external javascript?

Did you try the keyboard component?

Regarding you actual question, you can access the store by using clientside callbacks.

1 Like

Here is an example for the clientside callbacks using a hidden button:

from dash import Dash, dcc, html, Input, Output, State

app = Dash(__name__)

app.layout = html.Div([
    dcc.Store(id='store', data=0),
    html.Button(id = 'hidden-button', style={'display':'none'}),
        type = 'number'

    Output('store', 'data'),
    [Input('numeric-input', 'value')]
def update_store(value):
    return value

function(n, data){
    if(n) alert(data);
    return "";
    Output('hidden-button', 'title'), #output dummy
    Input('hidden-button', 'n_clicks'),
    State('store', 'data'),

if __name__ == '__main__':

and in assets/script.js something like:

  document.addEventListener('keydown', function(event) {
    if (event.key === 'Enter') {
      button = document.getElementById('hidden-button')

This might be interesting for you.