Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check exitVR property of keyboard-shortcuts to enable Escape shortcut #5512

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/components/keyboard-shortcuts.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ keyboard-shortcuts component applies only to the [`<a-scene>` element][scene].
## Example

```html
<a-scene keyboard-shortcuts="enterVR: false"></a-scene>
<a-scene keyboard-shortcuts="enterVR: false; exitVR: false;"></a-scene>
```

## Properties

| Property | Description | Default Value |
|-------------|-------------------------------------------------------|---------------|
| enterVR | Enables the shortcut to press 'F' to enter VR. | true |
| exitVR | Enables the shortcut to press 'Escape' to exit VR. | true |
9 changes: 2 additions & 7 deletions src/components/scene/keyboard-shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ module.exports.Component = registerComponent('keyboard-shortcuts', {
this.onKeyup = this.onKeyup.bind(this);
},

update: function (oldData) {
var data = this.data;
this.enterVREnabled = data.enterVR;
},

play: function () {
window.addEventListener('keyup', this.onKeyup, false);
},
Expand All @@ -29,10 +24,10 @@ module.exports.Component = registerComponent('keyboard-shortcuts', {
onKeyup: function (evt) {
var scene = this.el;
if (!shouldCaptureKeyEvent(evt)) { return; }
if (this.enterVREnabled && evt.keyCode === 70) { // f.
if (this.data.enterVR && evt.keyCode === 70) { // f.
scene.enterVR();
}
if (this.enterVREnabled && evt.keyCode === 27) { // escape.
if (this.data.exitVR && evt.keyCode === 27) { // escape.
scene.exitVR();
}
}
Expand Down