Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to Paste code to NoVNC.
// This will open up a prompt for text to send to a console session on digital ocean
// Useful for long passwords
(function () {
window.sendString = function (str) {
function f(t) {
var character = t.shift();
var i=[];
var code = character.charCodeAt();
var needs_shift = character.match(/[A-Z!@#$%^&*()_+{}:\"<>?~|]/);
if (needs_shift) {
if (needs_shift) {
if (t.length > 0) {
setTimeout(function() {f(t);}, 10);
# Minified Version:
(function(){window.sendString=function(a){function b(c){var d=c.shift(),g=d.charCodeAt(),h=d.match(/[A-Z!@#$%^&*()_+{}:\"<>?~|]/);h&&rfb.sendKey(XK_Shift_L,1),rfb.sendKey(g,1),rfb.sendKey(g,0),h&&rfb.sendKey(XK_Shift_L,0),0<c.length&&setTimeout(function(){b(c)},10)}b(a.split(""))}})();

This comment has been minimized.

Copy link
Owner Author

commented Oct 12, 2017

I started digging into the code following the forum and

The changes I did are:

  • Support A-Z uppercase characters;
  • The RFB.messages.keyEvent() changed and now requires rfb._sock. So, I simply change it to rfb.sendKey();
  • Remove the prompt and added the sendString() method;

I successfully tested it on:

  • EMBRATEL Cloud Service;
  • Digital Ocean.
  • Vultr;


Open the developer tool box and paste the JavaScript above in the "console".

To send a string use:

sendString('string to be typed');

Let me know if it works


This comment has been minimized.

Copy link

commented Mar 11, 2018

I've to open a console on which window?
I'm unable to open chrome console for DigitalOcean window console..


This comment has been minimized.

Copy link

commented Mar 17, 2018

how does one use this ? maybe a set of "for-dummies" instruction might be useful. thanks.


This comment has been minimized.

Copy link

commented Sep 5, 2018

@blondie63 Try the CTRL+SHIFT+I shortcut if right-clicking is not available

@katahdin0 Read byjg's comment...

@byjg Worked great for me on Vultr!


This comment has been minimized.

Copy link

commented Jan 22, 2019

Solution doesn't work for characters like !@#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.