【发布时间】:2018-02-13 14:27:15
【问题描述】:
是否可以在 AFRAME 实体上捕获特定的键盘按键事件?
我通过实体上的 addEventListener 进行了尝试,但似乎事件不会传播到实体(有和没有 wasd-controls)。
AFRAME.registerComponent('listenonclick', {
...
init: function () {
...
this.el.addEventListener('keydown', function(event) {
console.log("onkeydown Button" + event.code);
});
...
<a-box listenonclick id='box1' ..."></a-box>
但是,当将事件添加到窗口而不是实体时,它将被触发。
【问题讨论】:
标签: javascript three.js aframe