How to keep the focus on a canvas always?

前端 未结 3 1679
醉话见心
醉话见心 2021-01-12 05:12

I\'ve been looking for a solution in this forum, but not found yet. I need to keep the focus on a canvas element always, no matter where i click on the page. I have several

3条回答
  •  囚心锁ツ
    2021-01-12 05:52

    What about this (using jQuery):

    $('#canvas').focus().blur(function() {
        $('#canvas').focus();
    });
    

    The idea is to give it the focus back every time it loses it (blur).

    I made an example (with a textbox which is basically the same) here: http://jsfiddle.net/thepeak/j02vyryf/

提交回复
热议问题