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
- Save the keyboard.onkeydown/onkeyup bound events elsewhere, set keyboard.onkeydown=null, keyboard.onkeyup=null. Then restore them when needed.
- Set the binding element for new Guacamole.Keyboard to the RDP desktop element
Related Documentation
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.