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

Set or remove key repetition and delay.

Started by Kingdaro, 03 February 2013 - 09:09 AM
Kingdaro #1
Posted 03 February 2013 - 10:09 AM
A problem with most games in CC is that their fluency is drastically lowered by the delay one gets before being able to have a key repeated a bunch of times. There should be a way to set the amount of delay before a key is repeated, and the time interval between which keys are repeated. Perhaps a function like "term.setKeyRepeat(delay, interval)". If one wanted to not have any delay before key repetition, you could set the delay to 0, and if one wanted to disable the repeating of keys (to make it so that a key couldn't be spammed at all whatsoever), you could set the interval to 0.

It would work similar to love2d's keyrepeat function, except setting the delay to 0 only removes the delay, and doesn't disable key repetition (this would be done by setting the interval to 0 instead).

https://www.love2d.org/wiki/love.keyboard.setKeyRepeat

EDIT: I'd also like to add that the shell program should reset the key repeat to default (what it is now) after a program is finished, so that there are no problems with typing in other programs.
tesla1889 #2
Posted 03 February 2013 - 10:12 AM
judging by the fact that dan and cloudy have always refused to implement the events "key_down" and "key_up", im pretty sure they won't go for this either

for most intents and purposes, the current key-event handling is sufficient
Kingdaro #3
Posted 03 February 2013 - 10:20 AM
It's not related to key down or key up events at all, it's simply being able to change the rate at which keypresses are repeated, perhaps limited to a point as to not cause too much server lag. Current event handling would be unchanged, I just won't have to wait half a second for my little spaceship to move to the right.
tesla1889 #4
Posted 03 February 2013 - 11:34 AM
im just simply presenting a trend. dan and cloudy dont seem to like to change anything related to keypress events.
Jan #5
Posted 03 February 2013 - 12:35 PM
Maybe the client should send 'key_repeat' events every 0.05 second or so after 'key' was send.
That way old programs would function normally, and programs who want to handle hold-down could listen to 'key_repeat'.
Furthermore this avoids the 'multiple users on one monitor' problem.
Kingdaro #6
Posted 03 February 2013 - 12:42 PM
Maybe the client should send 'key_repeat' events every 0.05 second or so after 'key' was send.
That way old programs would function normally, and programs who want to handle hold-down could listen to 'key_repeat'.
Furthermore this avoids the 'multiple users on one monitor' problem.
Old programs would function normally anyway, as the key delay/repeat interval would be set to default when a program is run, and a program can change it if it pleases. With this system, there would be no problems with a multiuser environment, only more key events.

People, this does not relate at all to a key_down or key_up event, just a way to make games/programs that rely on rapid keypresses easier to use.
tesla1889 #7
Posted 03 February 2013 - 12:57 PM
–snip–
People, this does not relate at all to a key_down or key_up event, just a way to make games/programs that rely on rapid keypresses easier to use.

i wasnt saying it was

i was just saying that the CC devs don't like to change that type of thing
Cloudy #8
Posted 04 February 2013 - 12:05 AM
I've never outright refused key up events, so don't talk shit.

But no, this won't happen. Key repeat is handled client side right now.
tesla1889 #9
Posted 04 February 2013 - 06:05 AM
I've never outright refused key up events, so don't talk shit.
–snip–
im not talking shit, im just telling him you'll probably say no
JJRcop #10
Posted 06 February 2013 - 02:07 PM
-snip-
im not talking shit, im just telling him you'll probably say no
Dan and clowdy are not against changing key input things, they are against making things that don't work well/at all in a multi-user environment.
Pharap #11
Posted 06 February 2013 - 04:34 PM
Why not just set up an event interceptor that detects key events, then outputs the key data along with the difference in minecraft world time since the last press so the programmer knows how long it has been since the user pressed the last key. That's pretty much how you test it in proper game engines, so it should just about work with CC.
tesla1889 #12
Posted 06 February 2013 - 04:39 PM
–snip–

i like this idea, but only for making double-click detection easier
Pharap #13
Posted 06 February 2013 - 04:47 PM
i like this idea, but only for making double-click detection easier

Again, how you have to do it in most game engines (gets annoying after the 3rd/4th project, makes you want to write a library but never get round to it).
It's a shame keyboards and mice don't have their own clocks or ways of interfacing with the computer clock, it would save a lot of trouble if peripheral drivers could give the time between button presses/mouse clicks etc.