Keyboard event only when focus is in the canvas
This commit is contained in:
parent
0386263d58
commit
18665ecd03
|
@ -35,4 +35,4 @@ button.
|
|||
|
||||
</div>
|
||||
|
||||
<div id="container" style="padding: 0px; margin: 0px;"></div>
|
||||
<div id="container" style="padding: 0px; margin: 0px;" tabindex="1"></div>
|
||||
|
|
|
@ -46,8 +46,8 @@ var PointerCamera = function() {
|
|||
var onMouseMove = function(event) {self.onMouseMove(event); };
|
||||
var onMouseUp = function(event) {self.onMouseUp(event); };
|
||||
|
||||
document.addEventListener('keydown', onKeyDown, false);
|
||||
document.addEventListener('keyup', onKeyUp, false);
|
||||
listenerTarget.addEventListener('keydown', onKeyDown, false);
|
||||
listenerTarget.addEventListener('keyup', onKeyUp, false);
|
||||
listenerTarget.addEventListener('mousedown', function(event) { if (event.which == 1) onMouseDown(event);}, false);
|
||||
listenerTarget.addEventListener('mousemove', function(event) { if (event.which == 1) onMouseMove(event);}, false);
|
||||
listenerTarget.addEventListener('mouseup', onMouseUp, false);
|
||||
|
|
Loading…
Reference in New Issue