ONOS-1865 - GUI -- Keys from Topo View are deregistered once view is navigated away from. Device and App View 'esc' key registration added.

Change-Id: I88896266936a4f148007170d67058036fb365fe5
diff --git a/web/gui/src/main/webapp/app/view/app/app.js b/web/gui/src/main/webapp/app/view/app/app.js
index c5a7961..5bcb428 100644
--- a/web/gui/src/main/webapp/app/view/app/app.js
+++ b/web/gui/src/main/webapp/app/view/app/app.js
@@ -31,8 +31,9 @@
     .controller('OvAppCtrl',
         ['$log', '$scope', '$http',
         'FnService', 'TableBuilderService', 'WebSocketService', 'UrlFnService',
+        'KeyService',
 
-    function ($log, $scope, $http, fs, tbs, wss, ufs) {
+    function ($log, $scope, $http, fs, tbs, wss, ufs, ks) {
         $scope.ctrlBtnState = {};
         $scope.uploadTip = 'Upload an application';
         $scope.activateTip = 'Activate selected application';
@@ -42,8 +43,6 @@
         function selCb($event, row) {
             // selId comes from tableBuilder
             $scope.ctrlBtnState.selection = !!$scope.selId;
-            $log.debug('Got a click on:', row);
-
             refreshCtrls();
         }
 
@@ -68,6 +67,16 @@
             respCb: refreshCtrls
         });
 
+        // TODO: reexamine where keybindings should be - directive or controller?
+        ks.keyBindings({
+            esc: [$scope.selectCallback, 'Deselect app'],
+            _helpFormat: ['esc']
+        });
+        ks.gestureNotes([
+            ['click row', 'Select / deselect app'],
+            ['scroll down', 'See more apps']
+        ]);
+
         $scope.appAction = function (action) {
             if ($scope.ctrlBtnState.selection) {
                 $log.debug('Initiating ' + action + ' of ' + $scope.selId);
@@ -95,6 +104,10 @@
             }
         });
 
+        $scope.$on('$destroy', function () {
+            ks.unbindKeys();
+        });
+
         $log.log('OvAppCtrl has been created');
     }])