我正在尝试使用节点js制作一个程序,该程序将捕获按键和鼠标移动。不在Web浏览器上。这是我个人项目中的一种键盘记录器类型。我尝试了robotjs,但它需要很多依赖才能运行。有没有简单的方法来做到这一点。 感谢提前节点js捕获键盘按键和鼠标移动(不在Web浏览器上)
3
A
回答
0
您是否尝试过使用按键模块?从回购https://github.com/TooTallNate/keypress
实例为KEY:从回购
var keypress = require('keypress');
// use decoration to enable stdin to start sending ya events
keypress(process.stdin);
// listen for the "keypress" event
process.stdin.on('keypress', function (ch, key) {
console.log('got "keypress"', key);
if (key && key.ctrl && key.name == 'c') {
process.stdin.pause();
}
});
process.stdin.setRawMode(true);
process.stdin.resume();
实例为鼠标: VAR按键=要求( '按键');
// make `process.stdin` begin emitting "mousepress" (and "keypress") events
keypress(process.stdin);
// you must enable the mouse events before they will begin firing
keypress.enableMouse(process.stdout);
process.stdin.on('mousepress', function (info) {
console.log('got "mousepress" event at %d x %d', info.x, info.y);
});
process.on('exit', function() {
// disable mouse on exit, so that the state
// is back to normal for the terminal
keypress.disableMouse(process.stdout);
});
+1
是的我试过了,但这不是我正在寻找的东西,我只是想要类似于真正的密钥记录器实际上追踪我的按键/释放无论我键入和点击 –
1
看起来像你需要全局钥匙钩。
尝试使用iohook模块
'use strict';
const ioHook = require('iohook');
ioHook.on("mousemove", event => {
console.log(event);
// result: {type: 'mousemove',x: 700,y: 400}
});
ioHook.on("keypress", event => {
console.log(event);
// result: {keychar: 'f', keycode: 19, rawcode: 15, type: 'keypress'}
});
//Register and stark hook
ioHook.start();
它是跨平台的本机模块,适用于Windows,Linux和MacOS的
相关问题
- 1. 防止在所有浏览器的div内捕获鼠标和键盘事件
- 2. 在黑莓键盘上捕获按键
- 3. 键盘按键捕获
- 4. 捕获Web浏览器控件的鼠标右键单击事件
- 5. 在浏览器中捕获热键
- 6. 在键盘上按下Enter键不等于在Android中点击鼠标吗?
- 7. 如何模拟键盘/鼠标按键?
- 8. 捕获鼠标左键点击
- 9. 在C中捕获和发送键盘/鼠标输入#
- 10. LWJGL键盘和鼠标检测按
- 11. 如何使Flex只在鼠标滚动和键盘事件有用时消耗鼠标滚动和键盘事件,否则将它传递给浏览器?
- 12. 禁用键盘和鼠标
- 13. 同时捕获鼠标和键盘事件
- 14. 鼠标悬停动画不上按鼠标右键,工作快速移动
- 15. .NET WinForms:暂停代码,直到鼠标移动或键盘按
- 16. 如何自动化鼠标和键盘?
- 17. JAVA用鼠标点击,用键盘移动
- 18. 如何在鼠标左键按下时检测鼠标移动?
- 19. Web浏览器无法捕获Windows键+ D,为什么?
- 20. 捕获键盘快捷键和转发
- 21. Sikuli不牺牲鼠标和键盘
- 22. 鼠标移动捕获
- 23. 使用移动浏览器捕获UDID
- 24. 鼠标移动捕获(鼠标离开和鼠标输入)
- 25. AutoHotKey点击鼠标右键也可以获得一个键盘按钮
- 26. “鼠标键”和“鼠标键”的键码
- 27. 使用鼠标中键滚动按钮禁用浏览器滚动
- 28. 如何区分“使用鼠标右键点击”和“物理键盘上的上下文菜单键按下”
- 29. 如何在按钮上捕获鼠标移动
- 30. 所有浏览器上的闪存键盘焦点
你尝试过:https://www.npmjs.com/package/keylogger – AlwaysNull
是,这个包完全是垃圾。它只存储您在终端上输入的内容。没有别的 –
你到目前为止尝试过什么?这使人们很容易给你一个答案。 – AlwaysNull