From a76f48f50bf8c69ed401164d68c4211468bf934e Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Wed, 14 May 2014 14:17:26 +0100 Subject: [PATCH] Add alt key hook to keyboard event handler (just in case :-) --- public/red/ui/keyboard.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/public/red/ui/keyboard.js b/public/red/ui/keyboard.js index 25103ea88..50a48fc7c 100644 --- a/public/red/ui/keyboard.js +++ b/public/red/ui/keyboard.js @@ -14,17 +14,18 @@ * limitations under the License. **/ RED.keyboard = function() { - + var active = true; var handlers = {}; - + d3.select(window).on("keydown",function() { if (!active) { return; } var handler = handlers[d3.event.keyCode]; if (handler && handler.ondown) { if (!handler.modifiers || - ((!handler.modifiers.shift || d3.event.shiftKey)&& - (!handler.modifiers.ctrl || d3.event.ctrlKey))) { + ((!handler.modifiers.shift || d3.event.shiftKey) && + (!handler.modifiers.ctrl || d3.event.ctrlKey ) && + (!handler.modifiers.alt || d3.event.altKey ) )) { handler.ondown(); } } @@ -34,8 +35,9 @@ RED.keyboard = function() { var handler = handlers[d3.event.keyCode]; if (handler && handler.onup) { if (!handler.modifiers || - ((!handler.modifiers.shift || d3.event.shiftKey)&& - (!handler.modifiers.ctrl || d3.event.ctrlKey))) { + ((!handler.modifiers.shift || d3.event.shiftKey) && + (!handler.modifiers.ctrl || d3.event.ctrlKey ) && + (!handler.modifiers.alt || d3.event.altKey ) )) { handler.onup(); } } @@ -44,7 +46,7 @@ RED.keyboard = function() { var mod = modifiers; var cbdown = ondown; var cbup = onup; - + if (typeof modifiers == "function") { mod = {}; cbdown = modifiers; @@ -55,7 +57,7 @@ RED.keyboard = function() { function removeHandler(key) { delete handlers[key]; } - + return { add: addHandler, remove: removeHandler,