GUACAMOLE-817: Merge reset keyboard state on navigation and form submission.

diff --git a/guacamole/src/main/webapp/app/index/controllers/indexController.js b/guacamole/src/main/webapp/app/index/controllers/indexController.js
index 15e7819..ac2fec4 100644
--- a/guacamole/src/main/webapp/app/index/controllers/indexController.js
+++ b/guacamole/src/main/webapp/app/index/controllers/indexController.js
@@ -138,6 +138,12 @@
         keyboard.reset();
     };
 
+    // Release all keys upon form submission (there may not be corresponding
+    // keyup events for key presses involved in submitting a form)
+    $document.on('submit', function formSubmitted() {
+        keyboard.reset();
+    });
+
     /**
      * Checks whether the clipboard data has changed, firing a new
      * "guacClipboard" event if it has.
@@ -188,6 +194,11 @@
         $scope.fatalError = error;
     });
 
+    // Ensure new pages always start with clear keyboard state
+    $scope.$on('$routeChangeStart', function routeChanging() {
+        keyboard.reset();
+    });
+
     // Update title and CSS class upon navigation
     $scope.$on('$routeChangeSuccess', function(event, current, previous) {