aframevr / aframevr/aframe

Using WASD controls not working when scene is embedded (and body isn't the document.activeElement)

Open
#2,304 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
17.6k
Forks
4.4k
PR merge metrics
No merged PRs in 30d

Description

Description:

The scene is embedded inside a bootstrap modal dialog and the shouldCaptureKeyEvent method ( https://github.com/aframevr/aframe/blob/master/src/utils/index.js#L176 ) returns false because, in my case document.activeElement is the modal dialog div which does not equal to the document.body.

return document.activeElement === document.body;

What is the reason for this statement?

  • A-Frame Version: 0.4.0
  • Platform / Device: Chrome, Firefox
  • Reproducible Code Snippet or URL:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The relevant entry point is shouldCaptureKeyEvent in src/utils/index.js around line 176; first inspect why it requires document.activeElement to be document.body and reproduce the Bootstrap modal case in Chrome or Firefox. Done means agreeing on the intended focus behavior for embedded scenes and verifying that WASD input works without capturing keystrokes intended for the modal.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.