guacamole-common-js

· 1 min read

Recently encountered an issue where after the remote desktop is started, switching to other tab pages causes input events to fail.

var keyboard = new Guacamole.Keyboard(document);

keyboard.onkeydown = function(keysym) {
// Do something ...
};

keyboard.onkeyup = function(keysym) {
// Do something ...
};

The code is roughly as shown above.

Cause

Guacamole.Keyboard captures events and prevents bubbling, so as long as it’s not destroyed, it will continue to capture all keyboard events on the webpage.

Solution

  1. Save the keyboard.onkeydown/onkeyup bound events elsewhere, set keyboard.onkeydown=null, keyboard.onkeyup=null. Then restore them when needed.
  2. Set the binding element for new Guacamole.Keyboard to the RDP desktop element

Final Thoughts

This issue demonstrates the importance of understanding how Guacamole’s keyboard event handling works. The solution involves either temporarily disabling the keyboard event handlers or binding them to a more specific element to prevent them from capturing events across the entire document when not needed.

Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover