Jump to content




If key is pressed, not key event


  • You cannot reply to this topic
2 replies to this topic

#1 GeneralSocrates

  • New Members
  • 1 posts

Posted 02 June 2013 - 12:01 PM

I've been looking around a lot for this but I haven't found anything...
I've come up with an idea that would require me to check pressed keys on startup.

Note that I do not mean a key event, since the key would ALREADY be pressed and thus no event is triggered on startup.
I'm more like looking for a condition that would be translatable by "if key is pressed, then"

Any ideas?

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 03 June 2013 - 11:44 AM

Split into new topic.

It is not currently possible to determine the current state of a given key. However, keys that are held down continue to throw key events while they are held down. You could use a short timer to see if one of these events come in at startup.

#3 GopherAtl

  • Members
  • 888 posts

Posted 03 June 2013 - 03:48 PM

Just a minor clarification, only the last key pressed repeats while held. Not all held keys, and not the earliest pressed of those currently held; only the last one pressed. Ex.

Press and hold A, you get repeating A events; while still holding that, press and hold B, you now get repeating B events. Release B, you stop getting repeating events entirely. You do not resume getting A events. You can see this behavior easily by running "while true do print(os.pullEvent()) end" at a lua prompt.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users