Question

I'm trying to use jayq to allow me to use jquery with clojurescript.

For some reason this code works.

(bind ($ :#canvas) :mousedown
      (fn []
        (.log js/console (str "Why mouse but no keys?"))))

but this code doesn't.

(bind ($ :#canvas) :keydown
      (fn []
        (.log js/console (str "hit"))))

Is there any reason why the keydown event isn't caught properly

Was it helpful?

Solution

You have to make the canvas focusable, otherwise it won't receive any events. To do that, just give it a tabstop:

<canvas id="canvas" tabindex="1" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top