Вопрос

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

Это было полезно?

Решение

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" />
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top