From 18665ecd03f8ed9a3612e39a2cafa7d143280035 Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Mon, 27 Apr 2015 15:04:33 +0200 Subject: [PATCH] Keyboard event only when focus is in the canvas --- prototype/index.md | 2 +- static/js/PointerCamera.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/prototype/index.md b/prototype/index.md index 0fcaf5b..7058782 100644 --- a/prototype/index.md +++ b/prototype/index.md @@ -35,4 +35,4 @@ button. -
+
diff --git a/static/js/PointerCamera.js b/static/js/PointerCamera.js index e713cf5..eb80d8e 100644 --- a/static/js/PointerCamera.js +++ b/static/js/PointerCamera.js @@ -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);