1

There seems to be no keydown event associated with jointjs paper. How we can capture such event ?

Solutions that I tried:

Solution 1: Capture keydown on the div element (which holds paper). It didn't work.

$('#myholder).on('keydown', (e) => {
    console.log(e.which);
});

Solution 2: It seems a bit tough.

$(document).on('keydown', (e) => {
if( the previous event fired in 'blank:pointerdown' on paper and no other event is fired after that [which is equivalent to keydown on paper]) {
    console.log(e.which);
}

});

Sid
  • 76
  • 2
  • 8

1 Answers1

4

Answer in this question does the trick How to grab keyboard events on an element which doesn't accept focus?

$('#paper')
    .attr('tabindex', 0)
    .on('mouseover', function() {
        this.focus();
    })
    .on('keydown', function(e) {
        console.log(e.which);
    });

Also in the RappidJS (framework bases on the JointJS) there is the ui.Keyboard plugin which makes the keyboard handling easier http://resources.jointjs.com/docs/rappid/v2.1/ui.html#ui.Keyboard

vt.
  • 1,398
  • 7
  • 15