Polymer keypress event handler not being called

后端 未结 1 1905
北恋
北恋 2021-01-21 06:28

Can\'t figure out why in the following polymer I am unable to get the keypressHandler function to be called. What am I doing wrong? (I tried putting the on-keypress attribute

相关标签:
1条回答
  • 2021-01-21 07:06

    When you press a key, the system has to know where to send the event. This is why there is a concept of focus. For your element to receive keys it must be focused.

    You can make it focus-able by setting tabIndex, e.g.

    ready: function() { this.tabIndex = 0; }

    Now you can cause your element to be focused by calling the focus() method on the element (this.focus()), or by tabbing to it or clicking on it.

    Once your element is focused, it should receive key presses.

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