From 0a1184bde8d6ea4830f7717ec238cae69f0acebd Mon Sep 17 00:00:00 2001 From: Joel Martin <github@martintribe.org> Date: Wed, 15 Sep 2010 18:14:27 -0500 Subject: [PATCH] API change: add sendKey() to manually send key code. RFB.sendKey(code, down) If down is not specified then both a down followed by an up code will be sent. --- include/rfb.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/rfb.js b/include/rfb.js index 2cca10d..63eee82 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -1603,6 +1603,23 @@ that.sendCtrlAltDel = function() { send_array(arr); }; +// Send a key press. If 'down' is not specified then send a down key +// followed by an up key. +that.sendKey = function(code, down) { + if (rfb_state !== "normal") { return false; } + var arr = []; + if (typeof down !== 'undefined') { + Util.Info("Sending key code (" + (down ? "down" : "up") + "): " + code); + arr = arr.concat(keyEvent(code, down ? 1 : 0)); + } else { + Util.Info("Sending key code (down + up): " + code); + arr = arr.concat(keyEvent(code, 1)); + arr = arr.concat(keyEvent(code, 0)); + } + arr = arr.concat(fbUpdateRequest(1)); + send_array(arr); +}; + that.clipboardPasteFrom = function(text) { if (rfb_state !== "normal") { return; } //Util.Debug(">> clipboardPasteFrom: " + text.substr(0,40) + "..."); -- 2.18.1