I'm trying to use the RobotJS library to press the Windows key + L key, but I don't know how to point to the Windows key, and I'm not finding any answers online. Can you help me with this?
I've managed to make it work with Alt+Tab and some other combinations like this:
function pressAltTab() {
robot.keyToggle("alt", "down");
robot.keyTap("tab");
robot.keyToggle("alt", "up");
}
However, when I tried to simulate the Win+L combination using the following code:
function pressWindowsL() {
robot.keyToggle("home", "down");
robot.keyTap("l");
robot.keyToggle("home", "up");
}
I also attempted to use 'windows' instead of 'home,' but it didn't work either. When I use 'windows,' it throws an error: Uncaught Error Error: Invalid key code specified
. So, I believe 'home' is the correct term according to the docs, but it's not functioning as expected.
I even tried a simple code like this to verify if there's an issue unrelated to the keyToggle function, but it still doesn't work:
robot.keyToggle("windows", "down");
robot.keyToggle("windows", "up");
You'll need the command
key code as stated in this Github issue.