Search code examples
javascriptbrowserwebsocketoncopy

Handle oncopy event after server's response


I want to modify the user's clipboard when he presses CTRL+C based on what the server responds. The communication with the server is done through a web socket. I managed to get the oncopy event and I'm able to set some content to it, but only immediately. What I want is something like this:

  • oncopy event fired and caught
  • ask the server for something (socket.send(bla bla))
  • receive answer from the server (socket.onmessage())
  • update the user's clipboard by editing event.clipboardData

Is it possible?

Or is there a way in which I could do busy waiting in the event handling method while the message from the server is being received?


Solution

  • Sorry, playing around with a clipboard is tricky business. What I have found out is that after a while the clipboard data are lost from the event object (might be a security meassure). So you either set the data immedietly or you loose the ability to set it.