How to listen to Keydown-Events in a KineticJS-managed HTML5-Canvas?


To listen to KeyDown events, use −

if(keyIsPressed && keycode == somenumber) {
   doSomething();
}

To capture KeyDown −

var canvas1 = layer.getCanvas()._canvas;
$(canvas1).attr('tabindex', 1);
canvas1.focus();

$(canvas1).keydown(function (event) {
   console.log(event);
});

Updated on: 25-Jun-2020

65 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements