From 37007cc81f523a2ad3ff57f56203b95ab79d282f Mon Sep 17 00:00:00 2001 From: Karim Allah Ahmed Date: Tue, 6 Mar 2012 16:35:49 +0200 Subject: [PATCH] Tiny fix for cases when 'alt' or 'ctl' is stuck at 'keyDown' when the window loses focus. --- include/rfb.js | 10 ++++++++++ vnc.html | 3 +++ vnc_auto.html | 3 +++ 3 files changed, 16 insertions(+) diff --git a/include/rfb.js b/include/rfb.js index 13fdd0a6..5b64ba9b 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -1617,6 +1617,16 @@ that.sendKey = function(code, down) { ws.send(arr); }; +// Sending UP keys for all control keys, used because of the keypress and hold effect issues VNC. +that.resetKeyboard = function(code, down) { + that.sendKey(0xffe9, 0); // alt ( left ) + that.sendKey(0xffea, 0); // alt ( right ) + that.sendKey(0xffe3, 0); // ctrl( left ) + that.sendKey(0xffe4, 0); // ctrl ( right ) + that.sendKey(0xffe2, 0); // shift ( right ) + that.sendKey(0xffe1, 0); // shift ( right ) +}; + that.clipboardPasteFrom = function(text) { if (rfb_state !== "normal") { return; } //Util.Debug(">> clipboardPasteFrom: " + text.substr(0,40) + "..."); diff --git a/vnc.html b/vnc.html index b6cf85ba..0e8e61b3 100644 --- a/vnc.html +++ b/vnc.html @@ -193,6 +193,9 @@ diff --git a/vnc_auto.html b/vnc_auto.html index 77df8bb0..a8206978 100644 --- a/vnc_auto.html +++ b/vnc_auto.html @@ -60,6 +60,9 @@ rfb.sendCtrlAltDel(); return false; } + window.onblur = function() { + rfb.resetKeyboard(); + } function updateState(rfb, state, oldstate, msg) { var s, sb, cad, level; s = $D('noVNC_status');