Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/donmccurdy/aframe-keyboard-controls
⌨️ Keyboard controls and input events for A-Frame VR.
https://github.com/donmccurdy/aframe-keyboard-controls
aframe
Last synced: 2 days ago
JSON representation
⌨️ Keyboard controls and input events for A-Frame VR.
- Host: GitHub
- URL: https://github.com/donmccurdy/aframe-keyboard-controls
- Owner: donmccurdy
- License: mit
- Archived: true
- Created: 2016-01-05T04:10:01.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-23T00:38:38.000Z (about 6 years ago)
- Last Synced: 2024-02-09T23:58:47.482Z (8 months ago)
- Topics: aframe
- Language: JavaScript
- Homepage:
- Size: 92.8 KB
- Stars: 23
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# A-Frame `keyboard-controls` Component
> **NOTICE**: This project is no longer maintained. I recommend using `movement-controls` from [A-Frame Extras](https://github.com/donmccurdy/aframe-extras) instead.
Keyboard controls for A-Frame.
## Overview
Bindings and events for keyboard controls on an A-Frame VR scene. When combined with [ProxyControls.js](https://proxy-controls.donmccurdy.com) (with the [proxy-controls](https://github.com/donmccurdy/aframe-proxy-controls) component for A-Frame), can also receive remote keyboard input by WebRTC.
## Usage
Movement + keyboard events:
```html
```
Keyboard events only (no movement):
```html
```
The full list of options can be seen in
[`keyboard-controls.js`](keyboard-controls.js).## Usage + Remote Device
[ProxyControls.js ⇢ Docs](http://localhost:3000/#/docs#remote-device)
Example:
```html
```
## Check Keyboard State
To check the pressed/unpressed state of a given [Keyboard.code](https://w3c.github.io/uievents-code/#code-value-tables), use the `isPressed()` method:
```javascript
var keyboardControls = el.components['keyboard-controls'];
keyboardControls.isPressed('ArrowLeft');
```## Events
`keyboard-controls` comes with a polyfill guaranteeing support for [KeyboardEvent.key](https://www.w3.org/TR/DOM-Level-3-Events-key/) and [KeyboardEvent.code](https://w3c.github.io/uievents-code/). When a `keydown` or `keyup` event is detected, an extra event is created with the `code` attached. Example usage:
```html
```
A complete list of `code` values may be found [here](https://w3c.github.io/uievents-code/#code-value-tables).
## Known Issues
In OS X, pressing the Command/Meta (⌘) key blocks all other key events. For example, pressing `A`, pressing `⌘`, releasing `A`, and then releasing `⌘` would create a `keydown:KeyA` event, but no `keyup:KeyA`. Because of this, I do not recommend using the Command/Meta key in your apps.