# Simple keyboard interaction with Makie visualization

**URL:** <https://discourse.julialang.org/t/simple-keyboard-interaction-with-makie-visualization/43215>\
**Category:** General Usage\
**Created:** [July 17, 2020, 6:48am UTC](https://discourse.julialang.org/t/simple-keyboard-interaction-with-makie-visualization/43215 "2020-07-17T06:48:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pauljurczak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pauljurczak/32/921_2.png) [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)\
**Post date:** [July 17, 2020, 6:48am UTC](https://discourse.julialang.org/t/simple-keyboard-interaction-with-makie-visualization/43215/1 "2020-07-17T06:48:59Z")

</div>

I want to visualize 2D/3D output of some function with different arguments depending on simple keyboard input: a key pressed produces new output for visualization. Here is a simple example:

```julia
using Makie

let
  npoints = 10
  points = Node(Point2f0.(rand(npoints), rand(npoints)))
  scene = Scene()
  scatter!(scene, points)
  display(scene)

  lift(scene.events.keyboardbuttons) do key
    # ispressed(key, Keyboard.q) && .....? 
    ispressed(key, Keyboard.down) && (npoints = max(2, npoints-1))
    ispressed(key, Keyboard.up) && (npoints += 1)

    println(npoints)
    points[] = Point2f0.(rand(npoints), rand(npoints))
    display(scene)
  end
end

```

It works, but I have these questions:

1. Each keystroke produces two events (key pressed and key released). I can’t find in Makie documentation how to distinguish between these two events, in order to have the visualization called only once per keystroke.
2. What is an easy way to find symbols for all keyboard keys/buttons other than looking at source code ([https://github.com/JuliaPlots/AbstractPlotting.jl/blob/master/src/interaction/iodevices.jl](https://github.com/JuliaPlots/AbstractPlotting.jl/blob/master/src/interaction/iodevices.jl))
3. Is this the intended way to implement what I described?
4. How to add an option to close visualization window on `q` pressed (commented line in code snippet above)
