# Makie plot not updating on key press

**URL:** <https://discourse.julialang.org/t/makie-plot-not-updating-on-key-press/66697>\
**Category:** Visualization\
**Tags:** makie, interactivity\
**Created:** [August 20, 2021, 1:39am UTC](https://discourse.julialang.org/t/makie-plot-not-updating-on-key-press/66697 "2021-08-20T01:39:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkoculak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkoculak/32/28310_2.png) [@mkoculak](https://discourse.julialang.org/u/mkoculak)\
**Post date:** [August 20, 2021, 1:39am UTC](https://discourse.julialang.org/t/makie-plot-not-updating-on-key-press/66697/1 "2021-08-20T01:39:46Z")

</div>

I am trying to make a simple plot updating on a keypress.  
I get the “step” to update when I press the keys, but the plot stays the same. I can’t seem to find any examples of such a case.  
It is probably something simple, but I can’t figure it out. Can anyone point me in the right direction?

```julia
using GLMakie

fig = Figure(resolution = (1920,1080));
ax = fig[1,1] = Axis(fig);
r = rand(200);

step = Node(1:100)

function step_back()
    global step.val = 10:110
end

function step_forw()
    global step.val = 5:105
end

on(events(fig).keyboardbutton) do event
    if event.action in (Keyboard.press, Keyboard.repeat)
        event.key == Keyboard.left && step_back()
        event.key == Keyboard.right && step_forw()
    end
    # Let the event reach other listeners
    return Consume(true)
end

lines!(@lift(r[$step,1]));
display(fig);

```

---

<div class="post-metadata">

**Author:** ![ffreyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffreyer/32/21569_2.png) [@ffreyer](https://discourse.julialang.org/u/ffreyer)\
**Post date:** [August 20, 2021, 11:18am UTC](https://discourse.julialang.org/t/makie-plot-not-updating-on-key-press/66697/2 "2021-08-20T11:18:15Z")

</div>

`node.val = ...` updates the value the node holds rather than triggering it. You should be using `node[] = ...`. (Btw `Consume(true)` is blocking, so the comment there is wrong.)

---

<div class="post-metadata">

**Author:** ![mkoculak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkoculak/32/28310_2.png) [@mkoculak](https://discourse.julialang.org/u/mkoculak)\
**Post date:** [August 20, 2021, 6:46pm UTC](https://discourse.julialang.org/t/makie-plot-not-updating-on-key-press/66697/3 "2021-08-20T18:46:49Z")

</div>

Thank you! This works like a charm.  
I suspected I was missing a minor detail (square brackets are a surprise for me, but I am super fresh with Julia).

As for the comment, it was copied with the code from somewhere in the Makie docs.  
I’ll probably go ask on github if they could sort out the docs and create a minimal example that will help people in the future.
