# How do you hijack keyboard controls in Jupyter using Julia?

**URL:** <https://discourse.julialang.org/t/how-do-you-hijack-keyboard-controls-in-jupyter-using-julia/9327>\
**Category:** General Usage\
**Tags:** question\
**Created:** [February 26, 2018, 1:37am UTC](https://discourse.julialang.org/t/how-do-you-hijack-keyboard-controls-in-jupyter-using-julia/9327 "2018-02-26T01:37:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [February 26, 2018, 1:37am UTC](https://discourse.julialang.org/t/how-do-you-hijack-keyboard-controls-in-jupyter-using-julia/9327/1 "2018-02-26T01:37:06Z")

</div>

Let’s say you’re building a game in Jupyter using Julia.

Eventually, you’ll need to use the arrow keys to move something around a maze (or play 2048)

What is the best way to highjack keyboard controls?

* * *

The idea would be that:

- some HTML is already rendered and
- anything keyboard related would end with a Javascript call

similar topics:

- [Detecting keystrokes in Julia](https://stackoverflow.com/questions/23593986/detecting-keystrokes-in-julia)
- [Interact.jl’s Widget Code](https://github.com/JuliaGizmos/Interact.jl/blob/045f0ea17b0bbe46b0f82c9cc25cabbddcd3f788/src/widgets.jl#L225-L248)

**edit:** would it also be possible to make the key press have a time limit?

// akin to DDR, Guitar Hero, or `"Press 'X' to dodge!"`

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [February 26, 2018, 2:51am UTC](https://discourse.julialang.org/t/how-do-you-hijack-keyboard-controls-in-jupyter-using-julia/9327/2 "2018-02-26T02:51:42Z")

</div>

Jupyter’s interface is in Javascript, and you need Javascript to write new widgets or to do anything with the UI that goes outside the Jupyter message spec.

---

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [February 26, 2018, 5:13am UTC](https://discourse.julialang.org/t/how-do-you-hijack-keyboard-controls-in-jupyter-using-julia/9327/3 "2018-02-26T05:13:37Z")

</div>

But how can javascript talk to julia?

Is this in the docs somewhere?

* * *

basically the julia version of:

- [IPython Notebook: Javascript/Python Bi-directional Communication | Pythonic Perambulations](http://jakevdp.github.io/blog/2013/06/01/ipython-notebook-javascript-python-communication/)

---

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [February 28, 2018, 6:25am UTC](https://discourse.julialang.org/t/how-do-you-hijack-keyboard-controls-in-jupyter-using-julia/9327/4 "2018-02-28T06:25:02Z")

</div>

Best answer would be to use the WebIO Julia Gizmo:

> **[GitHub - JuliaGizmos/WebIO.jl: A bridge between Julia and the Web.](https://github.com/JuliaGizmos/WebIO.jl)**
>
> A bridge between Julia and the Web. Contribute to JuliaGizmos/WebIO.jl development by creating an account on GitHub.
