Detect KeyDown in CustomJS

Hello,

Is there way to check for KeyDown in plot js events?

I would like to know if Shift-Key is pressed.

E.g.

plot = Figure()

  callback = CustomJS(args={},

      code="""

      console.log('Callback');

      // Does not work!!!

     console.log(window.event.shiftKey);

      """)

  plot.js_on_event(events.SelectionGeometry, callback)

Raphael

Hello,

Is there way to check for KeyDown in plot js events?

I would like to know if Shift-Key is pressed.

E.g.

plot = Figure()

  callback = CustomJS(args={},

      code="""

      console.log('Callback');

      // Does not work!!!

     console.log(window.event.shiftKey);

      """)

  plot.js_on_event(events.SelectionGeometry, callback)





Raphael
···

On Friday, November 10, 2017 at 4:26:51 PM UTC+7, Raffs Walker wrote:

Hi Raffs,

I don’t think it’s possible with the current API, but you can register global handlers for keyup/keydown, store currently held keys and get this information from within a Bokeh CustomJS callback.

Regards,

Eugene

···

On Friday, November 10, 2017 at 11:27:10 PM UTC+7, Eugene Pakhomov wrote:

On Friday, November 10, 2017 at 4:26:51 PM UTC+7, Raffs Walker wrote:

Hello,

Is there way to check for KeyDown in plot js events?

I would like to know if Shift-Key is pressed.

E.g.

plot = Figure()

  callback = CustomJS(args={},

      code="""

      console.log('Callback');

      // Does not work!!!

     console.log(window.event.shiftKey);

      """)

  plot.js_on_event(events.SelectionGeometry, callback)





Raphael

Thanks Eugene for the input.

  At the moment I'm trying to overwrite the SelectTool  like this:

There is a function that can be overwritten. Perhaps
I find a hook there to get what I need.
Have a nice day,
Raffs

···

https://bokeh.pydata.org/en/latest/docs/user_guide/extensions_gallery/tool.html
keyUp

  On 2017-11-10 17:28, Eugene Pakhomov

wrote:

Hi Raffs,

      I don't think it's possible with the current API, but you

can register global handlers for keyup/keydown, store
currently held keys and get this information from within a
Bokeh CustomJS callback.

Regards,

Eugene

      On Friday, November 10, 2017 at 11:27:10 PM UTC+7, Eugene

Pakhomov wrote:

          On Friday, November 10, 2017 at 4:26:51 PM UTC+7, Raffs

Walker wrote:

Hello,

                Is there way to check for KeyDown in plot js

events?

I would like to know if Shift-Key is pressed.

E.g.

plot = Figure()

                callback = CustomJS(args={},

                    code="""

                    console.log('Callback');

                    // Does not work!!!

                   console.log(window.event.shiftKey);

                    """)

                plot.js_on_event(events.                    SelectionGeometry,

callback)

              Raphael

  You received this message because you are subscribed to the Google

Groups “Bokeh Discussion - Public” group.

  To unsubscribe from this group and stop receiving emails from it,

send an email to [email protected].

  To post to this group, send email to [email protected].

  To view this discussion on the web visit [https://groups.google.com/a/continuum.io/d/msgid/bokeh/e2607111-389d-438e-ac3c-d950320dfd9f%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/e2607111-389d-438e-ac3c-d950320dfd9f%40continuum.io?utm_medium=email&utm_source=footer).

  For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).