From 6a747d116f84fe55a4b1c6c4496b74879e54bde6 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Thu, 23 Mar 2017 11:56:27 -0400 Subject: [PATCH] GUACAMOLE-113: Capture Ctrl-Alt-End keypress in order to do something useful with it. --- .../client/controllers/clientController.js | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/guacamole/src/main/webapp/app/client/controllers/clientController.js b/guacamole/src/main/webapp/app/client/controllers/clientController.js index 88cfaa08f..86f6c1a18 100644 --- a/guacamole/src/main/webapp/app/client/controllers/clientController.js +++ b/guacamole/src/main/webapp/app/client/controllers/clientController.js @@ -72,7 +72,9 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams ALT_KEYS = {0xFFE9 : true, 0xFFEA : true, 0xFE03 : true, 0xFFE7 : true, 0xFFE8 : true}, CTRL_KEYS = {0xFFE3 : true, 0xFFE4 : true}, + END_KEYS = {0xFF57 : true, 0xFFB1 : true}, MENU_KEYS = angular.extend({}, SHIFT_KEYS, ALT_KEYS, CTRL_KEYS); + CAD_KEYS = angular.extend({}, ALT_KEYS, CTRL_KEYS, END_KEYS); /** * All client error codes handled and passed off for translation. Any error @@ -288,6 +290,16 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams return true; } + function checkCADHotkeyActive() { + for(var keysym in keysCurrentlyPressed) { + if(!CAD_KEYS[keysym]) { + return false; + } + } + + return true; + } + // Hide menu when the user swipes from the right $scope.menuDrag = function menuDrag(inProgress, startX, startY, currentX, currentY, deltaX, deltaY) { @@ -495,12 +507,12 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams // Record key as pressed keysCurrentlyPressed[keysym] = true; + var currentKeysPressedKeys = Object.keys(keysCurrentlyPressed); /* * If only menu keys are pressed, and we have one keysym from each group, * and one of the keys is being released, show the menu. */ if(checkMenuModeActive()) { - var currentKeysPressedKeys = Object.keys(keysCurrentlyPressed); // Check that there is a key pressed for each of the required key classes if(!_.isEmpty(_.pick(SHIFT_KEYS, currentKeysPressedKeys)) && @@ -522,6 +534,26 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams } } + if(checkCADHotkeyActive()) { + + // Check that there is a key pressed for each of the required key classes + if(!_.isEmpty(_.pick(ALT_KEYS, currentKeysPressedKeys)) && + !_.isEmpty(_.pick(CTRL_KEYS, currentKeysPressedKeys)) && + !_.isEmpty(_.pick(END_KEYS, currentKeysPressedKeys)) + ) { + + // Don't send this key event through to the client + event.preventDefault(); + + // Log the event + console.log('We should trigger Ctrl-Alt-Delete here.'); + + // Reset the keys pressed + keysCurrentlyPressed = {}; + keyboard.reset(); + } + } + }); // Update pressed keys as they are released, synchronizing the clipboard