was about to propose something about implementing about implementing .KeyDown and retriggering every tick and such ...
Anyway (TL;DR):
... Then I realized a key is held down when it isn't up.
- What I suggest now is an on_KeyUp event for the Mod API, which is triggered when a key is released. I am pretty sure that is a thing that is already ready made somewhere ready to picked up.
This will trigger as soon as they key is released
Code: Select all
script.on_event(defines.events.on_keyup([key name here]), [function name here])
Example:
A code that looks like this (assuming that my_key is set in data.lua)Code: Select all
function on_press(event) set_variable=true --example for setting some game settings only true while key is held down end function on_release(event) set_variable=false --example for setting some game settings only true while key is held down ... which will be undone here end script.on_event("my_key", on_press) script.on_event(defines.events.on_keyup("my_key), on_release)