fabric.js canvas listen for keyboard events?

前端 未结 1 736
情深已故
情深已故 2021-02-19 09:27

In my fabric application, I\'m currently listening for certain key presses such as the delete key, and deleting any selected elements. My method of listening for key presses is:

相关标签:
1条回答
  • 2021-02-19 10:15

    Here's what I've ended up doing: I've got a wrapper div around the canvas used by fabric, and I've added the event listener to this wrapper.

    var canvasWrapper = document.getElementById('canvasWrap');
    canvasWrapper.tabIndex = 1000;
    canvasWrapper.addEventListener("keydown", myfunc, false);
    

    This is working exactly like I want. The delete presses that happen inside a text box aren't picked up by the the listener.

    0 讨论(0)
提交回复
热议问题