I'm trying to listen to click events (To be exact, magnet pull from google cardboard) on Android Chrome, but this seems to not work if the device goes into VR mode. I'm using Samsung Galaxy S7 for testing:
JS:
window.addEventListener('click', function (evt) {
console.log("test")
});
On Samsung's built in Android browser, the log is printed both in and out of VR mode. In Android Chrome, logging is only shown when the browser is not in VR mode.
HTML:
<a-entity camera="userHeight: 1.6" restrict-position look-controls>
<a-entity cursor="fuse: true; fuseTimeout: 500"
position="0 0 -1"
geometry="primitive: ring; radiusInner: 0.02; radiusOuter: 0.03"
material="color: black; shader: flat">
</a-entity>
</a-entity>
I'm using A-Frame ver 0.7.0, but this issue is reproducible just from using native WebVR APIs as well.
I thought the canvas might be consuming the click events, so I tried to add the eventlistener to Canvas directly. This also did not work.
Is this a bug in Chrome? Is there any workaround? I just need to be able to listen to button presses.