This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Any chance we could get key up events?
Started by ElvishJerricco, 05 August 2012 - 06:22 AMPosted 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.
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¢
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¢
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.
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.
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.
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.
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.
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.
Posted 27 November 2012 - 05:54 AM
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).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.
Posted 27 November 2012 - 05:43 PM
I understand that we won't get key up/down, that makes sense, but couldn't we get key modifiers or some such thing?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).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.
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.
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).
Posted 28 November 2012 - 06:03 AM
Key up probably won't happen, but getting whether a key is up/down may come.