最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Listen for keyboard events and mouse movement outside of Electron app - Stack Overflow

programmeradmin2浏览0评论

I've been getting into a few Electron projects and I am trying to figure out how you could listen for any keypresses or and track mouse movement when the app is in the background. I am using the menubar plugin so the app is still running in the background.

I tried using the global-shortcut API but it looks like that is for shortcuts only and you can't register individual keystrokes. I've also looked over the API and have yet to find an event for keystrokes and mouse movements outside the app's main screen.

I've been getting into a few Electron projects and I am trying to figure out how you could listen for any keypresses or and track mouse movement when the app is in the background. I am using the menubar plugin so the app is still running in the background.

I tried using the global-shortcut API but it looks like that is for shortcuts only and you can't register individual keystrokes. I've also looked over the API and have yet to find an event for keystrokes and mouse movements outside the app's main screen.

Share Improve this question edited Sep 30, 2019 at 16:50 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Oct 7, 2015 at 7:36 cameronmoreaucameronmoreau 4071 gold badge7 silver badges14 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

This is outside of the realm of normal use-cases for an electron application. In order to do this you would need to develop a native module that calls into the corresponding native functions of the operating system.

For example on windows: C++ Win32 keyboard events

Making native addons for node: https://nodejs/api/addons.html

FYI, Native addons are very hard.

发布评论

评论列表(0)

  1. 暂无评论