From b2f3b587ec3d558966ecb349d9a57ff2505ecca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Mon, 1 Feb 2016 12:58:52 +0100 Subject: [PATCH] Events: paper namespace may not be initialized when key evens are emitted. --- src/event/Key.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/event/Key.js b/src/event/Key.js index cf765041..9b0d51cf 100644 --- a/src/event/Key.js +++ b/src/event/Key.js @@ -67,7 +67,7 @@ var Key = new function() { // based on whichever key is used for commands. command: { get: function() { - var agent = paper.agent; + var agent = paper && paper.agent; return agent && agent.mac ? this.meta : this.control; } } @@ -106,7 +106,7 @@ var Key = new function() { // Detect modifiers and mark them as pressed / released if (key.length > 1 && (name = Base.camelize(key)) in modifiers) { modifiers[name] = down; - var agent = paper.agent; + var agent = paper && paper.agent; if (name === 'meta' && agent && agent.mac) { // Fix a strange behavior on Mac where no keyup events are // received for any keys pressed while the meta key is down. @@ -136,7 +136,7 @@ var Key = new function() { DomEvent.add(document, { keydown: function(event) { var key = getKey(event), - agent = paper.agent; + agent = paper && paper.agent; // Directly handle any special keys (key.length > 1) in keydown, as // not all of them will receive keypress events. // Chrome doesn't fire keypress events for command and alt keys,