Topic #2: Keyboard & Mouse Event Library
This is my latest update on my WebRTC Remote Desktop Application. In this post, I’ll explain how I implemented the keyboard and mouse functionalities. 🖱️⌨️
As the title suggests, WebRTC is the core technology behind this application. However, since it’s designed to run exclusively on web browsers, I used Electron.js to package it on top of Node.js, making it easy to distribute as a binary. 💻🔧
Now, to simulate and control keyboard and mouse events, I decided to use Python’s pyautogui library. But here comes the challenge: how do I connect and pass data between JavaScript and Python? 🤔 There are two popular JavaScript libraries — Robot.js and Nut.js — that can achieve similar functionalities. So, why did I choose Python instead? 🐍
Here’s why: I tried both Robot.js and Nut.js, and while both are solid libraries, they come with their own complications. 🤷♂️ Robot.js has some setup issues and challenges when building the app, while Nut.js is easier to set up but slower in performance compared to pyautogui. 🐢 After comparing Nut.js and pyautogui, I found that Nut.js uses Robot.js behind the scenes, which doesn’t natively simulate keyboard and mouse events. This was a major factor in my decision to go with pyautogui, and that’s what I’m currently using in the alpha release of my app. 🚀
Will it be updated or enhanced? Absolutely! ✅ I’ve already started researching and working on ways to improve it further (natively). 🔍
In my next post, I’ll explain how I implemented the communication between JavaScript and Python. Stay tuned! 🔧📡