Home > OS >  Simulate ctrl alt del in react-vnc
Simulate ctrl alt del in react-vnc

Time:01-27

Start to using react-vnc to connect wss api (cloud server) on reactjs project

<VncScreen
      url='ws://your-vnc-url.com'
      scaleViewport
      background="#000000"
      style={{
        width: '75vw',
        height: '75vh',
      }}
      ref={ref}
    />

everything looks good and it connect successfully, but on windows screen of server I need press ctrl alt del to unlock, but I don't know how can I do this via react or react-vnc , is there any solution for this?

Is there any way to simulate ctrl alt del key on javascript or in react-vnc if not, so how can I press any key on vnc ?

CodePudding user response:

The onConnect, onDisconnect, and onCredentialsRequired callbacks can accept a single parameter rfb. This parameter is the RFB object, which is described by noVNC. Learn more about the RFB object here.

The RFB object should provide a method called sendCtrlAltDel (see API). Maybe you can listen for a specific keypress and call this function instead.

CodePudding user response:

If I understood this correctly you are trying to use javascript to force action on keyboard which can be considered overdoing on security level. Javascript can control only events coming from keyboard -one directional by setting event listeners or using onkeyup. One example of onkeyup is provided in snippet in case that is what might help you as solution for your case.

document.onkeyup = function (e) {
      if (e.ctrlKey && e.shiftKey && e.which == 32) {
        alert("CTRL SHIFT SPACE pressed on keyboard");
      }
    };
<p>Select this text to set focus on snippet iframe and press CTRL SHIFT SPACE to activate event.</p><p>Usually there is no needs to set focus if code runs in single page.</p>

  • Related