I am trying to add an Event Listener to a Htm5-Canvas which is managed by Kineticjs (the Canvas was created via a Stage of KineticJS).
I tried out (using jQuery):
$(selector).keydown( function(e) {... } )
with the following Selectors:
Only $(window) is working. After experimenting with plain Html5-Canvas i figured out, that the Canvas-Element has Built-in-Support for Keyboard-Events. So i think, KineticJS is doing something magic around here. Wrong Selector-Usage can be excluded.
I checked every Selector with this code: console.log( $(selector).length )
Can anyone help here? Thx in advance!
I suggest using one of the Keyboard Plugins out there:
They work well together with KineticJS.
If you can include javascript into it, here is the code:
if(keyIsPressed && keycode == somenumber){
doSomething();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With