This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ElvishJerricco's profile picture

Any chance we could get key up events?

Started by ElvishJerricco, 05 August 2012 - 06:22 AM
ElvishJerricco #1
Posted 05 August 2012 - 08:22 AM
It's a little awkward to do keyboard shortcuts of our own without this =/ best we can do is listen for the first key then hope that they didn't release it before pressing the next one, possibly unintentionally doing something stupid.
BigSHinyToys #2
Posted 05 August 2012 - 08:34 AM
It would be nice to know when keys are released but it would double the amount of events that occur. from 2 per press to 4 I think this may have a negative affect on performance.

another possibility would be a os.isKeyDown(keynumber) or term.isKeyDown(keynumber) returning true or false
that way no new events are made and you can still check for multiple keys being down.

but the above is just my 2¢
ElvishJerricco #3
Posted 05 August 2012 - 08:57 AM
It would be nice to know when keys are released but it would double the amount of events that occur. from 2 per press to 4 I think this may have a negative affect on performance.

another possibility would be a os.isKeyDown(keynumber) or term.isKeyDown(keynumber) returning true or false
that way no new events are made and you can still check for multiple keys being down.

but the above is just my 2¢

term/os.isKeyDown actually does sound much better than new events.
MysticT #4
Posted 05 August 2012 - 04:43 PM
This has been suggested before, and the problem is that it would be hard to detect when a key is down/up in multiplayer.
Pharap #5
Posted 06 August 2012 - 06:29 AM
I must admit, it would be a nice idea. If I knew more about Java or at least about how minecraft/computercraft are coded, I would make a suggestion on how to do it.
If I do suggest something, it will probably get torn to shreds though.
As for shortcuts, I reccomend finding a way to grab two keys at once, test what they are and then implement the shortcuts as a conditional response.
GopherAtl #6
Posted 19 August 2012 - 01:37 AM
If keyup/down events (in-game, or just between client-server, as either method still requires the latter) are not practical, how about just key modifiers added as a parameter to key events, so you can detect not just d, but shift-d or ctrl-d? Minimal extra data required, and no additional messages.
natedogith1 #7
Posted 26 November 2012 - 08:29 PM
Bumping because I like the idea. Also, a suggestion on implementation: one of the returned parameters for key events could be a unique table, either with a list of pressed keys or as something to be passed to a function that would check if a key is pressed.
Cranium #8
Posted 27 November 2012 - 05:54 AM
Bumping because I like the idea. Also, a suggestion on implementation: one of the returned parameters for key events could be a unique table, either with a list of pressed keys or as something to be passed to a function that would check if a key is pressed.
You must not have read the sticky about things not to suggest. Shortly after this post was created, it became official that this will NEVER happen because of the confusion it would cause in a multiuser environment(multiplayer).
natedogith1 #9
Posted 27 November 2012 - 05:43 PM
Bumping because I like the idea. Also, a suggestion on implementation: one of the returned parameters for key events could be a unique table, either with a list of pressed keys or as something to be passed to a function that would check if a key is pressed.
You must not have read the sticky about things not to suggest. Shortly after this post was created, it became official that this will NEVER happen because of the confusion it would cause in a multiuser environment(multiplayer).
I understand that we won't get key up/down, that makes sense, but couldn't we get key modifiers or some such thing?
Cranium #10
Posted 27 November 2012 - 05:52 PM
I would think it may not be hard to detect if there are at least two keys at once. That way you can add keyboard shortcuts to an os (ctrl c anyone?). However… it would be really difficult to separate out who is currently holding one key, and who just pressed another key. Again, it would be very hard to code for a multiuser environment. Still likely will not happen.
Cruor #11
Posted 28 November 2012 - 12:28 AM
Not possible due to multiplayer stuff. This has been answered a load of times(hence i don't belive that this topic should be open anymore).
Cloudy #12
Posted 28 November 2012 - 06:03 AM
Key up probably won't happen, but getting whether a key is up/down may come.