提交 ae993477 编写于 作者: M Mr.doob

Controls: Adding keydown/keyup events listener to window. Fixes #4311 and #4327.

上级 324220dc
...@@ -265,8 +265,9 @@ THREE.FirstPersonControls = function ( object, domElement ) { ...@@ -265,8 +265,9 @@ THREE.FirstPersonControls = function ( object, domElement ) {
this.domElement.addEventListener( 'mousemove', bind( this, this.onMouseMove ), false ); this.domElement.addEventListener( 'mousemove', bind( this, this.onMouseMove ), false );
this.domElement.addEventListener( 'mousedown', bind( this, this.onMouseDown ), false ); this.domElement.addEventListener( 'mousedown', bind( this, this.onMouseDown ), false );
this.domElement.addEventListener( 'mouseup', bind( this, this.onMouseUp ), false ); this.domElement.addEventListener( 'mouseup', bind( this, this.onMouseUp ), false );
this.domElement.addEventListener( 'keydown', bind( this, this.onKeyDown ), false );
this.domElement.addEventListener( 'keyup', bind( this, this.onKeyUp ), false ); window.addEventListener( 'keydown', bind( this, this.onKeyDown ), false );
window.addEventListener( 'keyup', bind( this, this.onKeyUp ), false );
function bind( scope, fn ) { function bind( scope, fn ) {
......
...@@ -260,8 +260,8 @@ THREE.FlyControls = function ( object, domElement ) { ...@@ -260,8 +260,8 @@ THREE.FlyControls = function ( object, domElement ) {
this.domElement.addEventListener( 'mousedown', bind( this, this.mousedown ), false ); this.domElement.addEventListener( 'mousedown', bind( this, this.mousedown ), false );
this.domElement.addEventListener( 'mouseup', bind( this, this.mouseup ), false ); this.domElement.addEventListener( 'mouseup', bind( this, this.mouseup ), false );
this.domElement.addEventListener( 'keydown', bind( this, this.keydown ), false ); window.addEventListener( 'keydown', bind( this, this.keydown ), false );
this.domElement.addEventListener( 'keyup', bind( this, this.keyup ), false ); window.addEventListener( 'keyup', bind( this, this.keyup ), false );
this.updateMovementVector(); this.updateMovementVector();
this.updateRotationVector(); this.updateRotationVector();
......
...@@ -570,12 +570,12 @@ THREE.OrbitControls = function ( object, domElement ) { ...@@ -570,12 +570,12 @@ THREE.OrbitControls = function ( object, domElement ) {
this.domElement.addEventListener( 'mousewheel', onMouseWheel, false ); this.domElement.addEventListener( 'mousewheel', onMouseWheel, false );
this.domElement.addEventListener( 'DOMMouseScroll', onMouseWheel, false ); // firefox this.domElement.addEventListener( 'DOMMouseScroll', onMouseWheel, false ); // firefox
this.domElement.addEventListener( 'keydown', onKeyDown, false );
this.domElement.addEventListener( 'touchstart', touchstart, false ); this.domElement.addEventListener( 'touchstart', touchstart, false );
this.domElement.addEventListener( 'touchend', touchend, false ); this.domElement.addEventListener( 'touchend', touchend, false );
this.domElement.addEventListener( 'touchmove', touchmove, false ); this.domElement.addEventListener( 'touchmove', touchmove, false );
window.addEventListener( 'keydown', onKeyDown, false );
}; };
THREE.OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype ); THREE.OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype );
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册