Can't bind to the keydown event using jayq
-
04-06-2021 - |
Вопрос
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" />
Не связан с StackOverflow