+ GuacamoleUI.display.addEventListener('touchstart', function(e) {
+
+ // Close menu if shown
+ GuacamoleUI.shadeMenu();
+
+ // Record touch location
+ if (e.touches.length == 1) {
+ var touch = e.touches[0];
+ long_press_start_x = touch.pageX;
+ long_press_start_y = touch.pageY;
+ }
+
+ // Start detection
+ GuacamoleUI.startLongPressDetect();
+
+ }, true);
+
+ // Stop detection if touch moves significantly
+ GuacamoleUI.display.addEventListener('touchmove', function(e) {
+
+ if (e.touches.length == 1) {
+
+ // If touch distance from start exceeds threshold, cancel long press
+ var touch = e.touches[0];
+ if (Math.abs(touch.pageX - long_press_start_x) >= 10
+ || Math.abs(touch.pageY - long_press_start_y) >= 10)
+ GuacamoleUI.stopLongPressDetect();
+
+ }
+
+ }, true);
+
+ // Stop detection if press stops
+ GuacamoleUI.display.addEventListener('touchend', GuacamoleUI.stopLongPressDetect, true);
+
+ // Close menu on mouse movement
+ GuacamoleUI.display.addEventListener('mousemove', GuacamoleUI.startMenuCloseDetect, true);
+ GuacamoleUI.display.addEventListener('mousedown', GuacamoleUI.startMenuCloseDetect, true);