I have a Lua script that works on Logitech G-Hub, and activates on the G4 key being pressed. It looks a bit like this:
function OnEvent(event, arg)
if (event == "G_PRESSED" and arg == 4) then
PressKey("s")
Sleep(200)
PressKey("lctrl")
Sleep(300)
...
end
end
It goes on to do a lot more. Anyway, I need it to stop doing its whole thing once the G4 key is released. So something like:
function OnEvent(event, arg)
if (event == "G_PRESSED" and arg == 4) then
PressKey("s")
if (event == "G_RELEASED" and arg == 4) then
return
end
Sleep(200)
if (event == "G_RELEASED" and arg == 4) then
return
end
PressKey("lctrl")
if (event == "G_RELEASED" and arg == 4) then
return
end
Sleep(300)
if (event == "G_RELEASED" and arg == 4) then
return
end
end
end
Now obviously, this is not going to work. Just giving an example. I need some sort of event listener inside the first if statement checking if the G4 button has been pressed.
Is it possible to have the function immediately terminate once the button is released, such that future commands do not execute?