Skip to content

Latest commit

 

History

History
53 lines (37 loc) · 1.98 KB

three-story-controls.keyboardadaptor.md

File metadata and controls

53 lines (37 loc) · 1.98 KB

Home > three-story-controls > KeyboardAdaptor

KeyboardAdaptor class

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

Remarks

See KeyboardAdaptorProps for all properties that can be passed to the constructor. See KeyboardAdaptorDiscreteEvent and KeyboardAdaptorContinuousEvent for emitted event signatures.

Example

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()

Constructors

Constructor Modifiers Description
(constructor)(props) Constructs a new instance of the KeyboardAdaptor class

Methods

Method Modifiers Description
connect()
disconnect()
isEnabled()
update()