Page 1 of 1

Keypress or Wait?

Posted: 02 Nov 2008, 23:33
by Stealth870
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)?

Re: Keypress or Wait?

Posted: 02 Nov 2008, 23:36
by Argh
Is there a way to detect in code if a key was pressed?
Yes, and it's easy to use, here's an example from P.U.R.E.:

Code: Select all

function widget:KeyPress(key, mods, isRepeat)
  if (key == KEYSYMS.ESCAPE) then

     Do Stuff Here.

  end
end

Re: Keypress or Wait?

Posted: 02 Nov 2008, 23:47
by Stealth870
Ok, awesome. Where can I find a list for all the keycodes?

Re: Keypress or Wait?

Posted: 12 Nov 2008, 16:54
by imbaczek
in the KEYSYMS table. look at its keys.