mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add alt key hook to keyboard event handler (just in case :-)
This commit is contained in:
parent
0e35b65afd
commit
a76f48f50b
@ -14,17 +14,18 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
RED.keyboard = function() {
|
RED.keyboard = function() {
|
||||||
|
|
||||||
var active = true;
|
var active = true;
|
||||||
var handlers = {};
|
var handlers = {};
|
||||||
|
|
||||||
d3.select(window).on("keydown",function() {
|
d3.select(window).on("keydown",function() {
|
||||||
if (!active) { return; }
|
if (!active) { return; }
|
||||||
var handler = handlers[d3.event.keyCode];
|
var handler = handlers[d3.event.keyCode];
|
||||||
if (handler && handler.ondown) {
|
if (handler && handler.ondown) {
|
||||||
if (!handler.modifiers ||
|
if (!handler.modifiers ||
|
||||||
((!handler.modifiers.shift || d3.event.shiftKey)&&
|
((!handler.modifiers.shift || d3.event.shiftKey) &&
|
||||||
(!handler.modifiers.ctrl || d3.event.ctrlKey))) {
|
(!handler.modifiers.ctrl || d3.event.ctrlKey ) &&
|
||||||
|
(!handler.modifiers.alt || d3.event.altKey ) )) {
|
||||||
handler.ondown();
|
handler.ondown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -34,8 +35,9 @@ RED.keyboard = function() {
|
|||||||
var handler = handlers[d3.event.keyCode];
|
var handler = handlers[d3.event.keyCode];
|
||||||
if (handler && handler.onup) {
|
if (handler && handler.onup) {
|
||||||
if (!handler.modifiers ||
|
if (!handler.modifiers ||
|
||||||
((!handler.modifiers.shift || d3.event.shiftKey)&&
|
((!handler.modifiers.shift || d3.event.shiftKey) &&
|
||||||
(!handler.modifiers.ctrl || d3.event.ctrlKey))) {
|
(!handler.modifiers.ctrl || d3.event.ctrlKey ) &&
|
||||||
|
(!handler.modifiers.alt || d3.event.altKey ) )) {
|
||||||
handler.onup();
|
handler.onup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -44,7 +46,7 @@ RED.keyboard = function() {
|
|||||||
var mod = modifiers;
|
var mod = modifiers;
|
||||||
var cbdown = ondown;
|
var cbdown = ondown;
|
||||||
var cbup = onup;
|
var cbup = onup;
|
||||||
|
|
||||||
if (typeof modifiers == "function") {
|
if (typeof modifiers == "function") {
|
||||||
mod = {};
|
mod = {};
|
||||||
cbdown = modifiers;
|
cbdown = modifiers;
|
||||||
@ -55,7 +57,7 @@ RED.keyboard = function() {
|
|||||||
function removeHandler(key) {
|
function removeHandler(key) {
|
||||||
delete handlers[key];
|
delete handlers[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
add: addHandler,
|
add: addHandler,
|
||||||
remove: removeHandler,
|
remove: removeHandler,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user