Home > three-story-controls > KeyboardAdaptor
Parse keyboard events and emit either dampened values for continuous keypresses, or trigger events named according to a provided keymapping.
Signature:
export declare class KeyboardAdaptor extends BaseAdaptor
Extends: BaseAdaptor
See KeyboardAdaptorProps for all properties that can be passed to the constructor. See KeyboardAdaptorDiscreteEvent and KeyboardAdaptorContinuousEvent for emitted event signatures.
Continuous adaptor
const keyboardAdaptor = new KeyboardAdaptor({ type: 'continuous', dampingFactor: 0.2 })
keyboardAdaptor.connect()
keyboardAdaptor.addEventListener('update', (event) => {
cube.rotation.y += event.deltas.right - event.deltas.left
cube.rotation.x += event.deltas.up - event.deltas.down
)}
function animate() {
keyboardAdaptor.update()
window.requestAnimationFrame(animate)
}
animate()
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(props) | Constructs a new instance of the KeyboardAdaptor class |
| Method | Modifiers | Description |
|---|---|---|
| connect() | ||
| disconnect() | ||
| isEnabled() | ||
| update() |