Is there a way to detect in code if a key was pressed?
Also, what is the best way to have your code "wait" for something. Trying to work on my Ferry widget again and at the moment I have it so that your transport is put on Wait, and you start Shift+Right Clicking to create the waypoints. When I'm done doing that, hitting W will activate the rest of the ferry actions (stop waiting, convert last point to unload zone, add load zone at current position, repeat). But I don't know of how to have my widget wait till I'm done. I think the last time I used a while() loop I froze something. Is there a proper way to either detect if they key is pressed, or perhaps if the unit started moving (while speed is not 0)?
Keypress or Wait?
Moderator: Moderators
Re: Keypress or Wait?
Yes, and it's easy to use, here's an example from P.U.R.E.:Is there a way to detect in code if a key was pressed?
Code: Select all
function widget:KeyPress(key, mods, isRepeat)
if (key == KEYSYMS.ESCAPE) then
Do Stuff Here.
end
end
- Stealth870
- Posts: 166
- Joined: 13 Sep 2004, 00:25
Re: Keypress or Wait?
Ok, awesome. Where can I find a list for all the keycodes?
Re: Keypress or Wait?
in the KEYSYMS table. look at its keys.