How to listen keyboard events on svg

前端 未结 1 846
被撕碎了的回忆
被撕碎了的回忆 2020-12-19 08:14

I have a svg and I can draw multiple shapes on this svg. Now my requirement is I want to listen keyboard events like ctrl+C, ctrl+V, ctrl+D, Esc, Delete so that I can copy,

1条回答
  •  失恋的感觉
    2020-12-19 08:56

    Because SVG is not an input-type, listen for the event on the window instead:

    $(window).on('keypress', function (evt){ ... })
    

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