How can I listen for clipboard events in node.js?

懵懂的女人 提交于 2019-12-03 17:38:55

问题


I want to be able to listen for clipboard events (the copy event more precisely) in node.js.

I've already used windows keyboard hooks in java... so I'm already a bit familiar with the topic.

And as I'm using Ubuntu 10.10 as my main OS, I'm most interested in a Ubuntu Desktop solution. (but I'd still love to know how to accomplish this for a Windows system too)

Any thoughts?

Thanks a lot in advance,

Jochen


回答1:


I suggest you look at the node-clipboard module and continually listen for changes to the clipboard using callbacks. Something like:

var clipboard = ""
function listenClipboard(){
    var new_clip = getClipboard()
    if (new_clip !== clipboard) {
        clipboard = new_clip
        handleClipboardChange(clipboard)
    }
    setTimeout(listenClipboard, 100)
}


来源:https://stackoverflow.com/questions/8584597/how-can-i-listen-for-clipboard-events-in-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!