disclaimer: I've never used x3dom, I was just poking around in the source code
there appears to be some code which disables keypress
handling
this.disableKeys = x3dElem.getAttribute("keysEnabled");
this.disableKeys = this.disableKeys ? (this.disableKeys.toLowerCase() == "true") : false;
which is later read when setting up the keypress
event handler:
this.onKeyPress = function (evt) {
if (!this.parent.disableKeys) {
evt.preventDefault();
this.parent.doc.onKeyPress(evt.charCode);
}
this.parent.doc.needRender = true;
}
So it appears setting keysEnabled=...
attribute can turn this off. The oddity appears to be that their logic is backwards (?) for the condition:
x3dElem.getAttribute("keysEnabled")
must be truthy (that is, it must have an attribute)
- if that is falsey,
this.disableKeys
is always false
- otherwise it is equal to that attribute's value lower-cased being equal to
'true'
So to disable keypress events, use <... keysEnabled="true" ...>
I made a github issue about the backwards logic, perhaps in the future it will be keysDisabled="true"
instead
update:
in the latest version the attribute has been renamed to disableKeys
so use <... disableKeys="true" ...>