diff --git a/include/rfb.js b/include/rfb.js index 365aca70..c7310423 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -600,6 +600,7 @@ checkEvents = function() { // The status of the VNC server side key modifers. var remote_status = {shift: false, ctrl: false, alt: false, altgr: false}; +var softKeyState = {ctrlKey: false, altKey: false}; keyPress = function(keysym, down, km) { var arr = []; @@ -615,13 +616,15 @@ keyPress = function(keysym, down, km) { // Send key events for modifiers to the vnc server when: // 1. the status of modifers have been changed // 2. this is a repeated keydown event for a modifer - if (remote_status.ctrl !== km.ctrlKey || keysym === 0xFFE3) { - arr = arr.concat(keyEvent(0xFFE3, km.ctrlKey)); // CTRL - remote_status.ctrl = km.ctrlKey; + var ctrlKey = km.ctrlKey || softKeyState.ctrlKey; + var altKey = km.altKey || softKeyState.altKey; + if (remote_status.ctrl !== ctrlKey || keysym === 0xFFE3) { + arr = arr.concat(keyEvent(0xFFE3, ctrlKey)); // CTRL + remote_status.ctrl = ctrlKey; } - if (remote_status.alt !== km.altKey || keysym === 0xFFE9) { - arr = arr.concat(keyEvent(0xFFE9, km.altKey)); // ALT - remote_status.alt = km.altKey; + if (remote_status.alt !== altKey || keysym === 0xFFE9) { + arr = arr.concat(keyEvent(0xFFE9, altKey)); // ALT + remote_status.alt = altKey; } if (remote_status.altgr !== km.altgrKey || keysym === 0xFE03) { arr = arr.concat(keyEvent(0xFE03, km.altgrKey)); // ALTGR @@ -1916,6 +1919,10 @@ that.sendKey = function(code, down) { ws.send(arr); }; +that.updateSoftKeyState = function(name, value) { + softKeyState[name] = value; +}; + that.clipboardPasteFrom = function(text) { if (rfb_state !== "normal") { return; } //Util.Debug(">> clipboardPasteFrom: " + text.substr(0,40) + "..."); diff --git a/include/ui.js b/include/ui.js index b3ea619e..9cdfdbd5 100644 --- a/include/ui.js +++ b/include/ui.js @@ -164,6 +164,8 @@ addMouseHandlers: function() { $D("connectButton").onclick = UI.toggleConnectPanel; $D("disconnectButton").onclick = UI.disconnect; $D("descriptionButton").onclick = UI.toggleConnectPanel; + $D("ctrlLockCheckBox").onclick = UI.updateSoftKeyState; + $D("altLockCheckBox").onclick = UI.updateSoftKeyState; $D("noVNC_clipboard_text").onfocus = UI.displayBlur; $D("noVNC_clipboard_text").onblur = UI.displayFocus; @@ -413,6 +415,10 @@ sendCtrlAltDel: function() { UI.rfb.sendCtrlAltDel(); }, +updateSoftKeyState: function() { + UI.rfb.updateSoftKeyState(this.value, this.checked); +}, + setMouseButton: function(num) { var b, blist = [0, 1,2,4], button; @@ -508,11 +514,19 @@ updateVisualState: function() { $D('clipboardButton').style.display = "inline"; $D('showKeyboard').style.display = "inline"; $D('sendCtrlAltDelButton').style.display = "inline"; + $D('ctrlLockCheckBox').style.display = "inline"; + $D('altLockCheckBox').style.display = "inline"; + $D('ctrlLockLabel').style.display = "inline"; + $D('altLockLabel').style.display = "inline"; } else { UI.setMouseButton(); $D('clipboardButton').style.display = "none"; $D('showKeyboard').style.display = "none"; $D('sendCtrlAltDelButton').style.display = "none"; + $D('ctrlLockCheckBox').style.display = "none"; + $D('altLockCheckBox').style.display = "none"; + $D('ctrlLockLabel').style.display = "none"; + $D('altLockLabel').style.display = "none"; } // State change disables viewport dragging. // It is enabled (toggled) by direct click on the button diff --git a/vnc.html b/vnc.html index 65c71581..efd5a230 100644 --- a/vnc.html +++ b/vnc.html @@ -70,6 +70,12 @@