123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|663|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Off Topic -> Speed Key

Sun, 31 Mar 2013, 05:06
dna
Can someone point me to a tutorial that shows how to process single key presses and repeating key presses when the key is held down?

-=-=-
DNA
Sun, 31 Mar 2013, 05:06
rockford
In what language? Most languages have their own way of doing things.

In GLB I'd do something like this

// No repeat keypress




//For repeated keys



WOT NO CODE BLOCKS Jay?
Mon, 01 Apr 2013, 05:44
waroffice
Strange cos I was going to try and figure this out as per my blog post. In glb too!


Mon, 01 Apr 2013, 05:52
Jayenkai
LOL, sorry!!.. I'll go switch off the sillyness.
Mon, 01 Apr 2013, 21:12
dna
I wanted it in blitz.

I was makin a paging algorithm that was supposed to continuously page until I released the Page Up or Page down key.

It now only pages a single keypress at a time with each press of a key.

-=-=-
DNA
Mon, 01 Apr 2013, 22:17
rockford
Well Blitz uses KEYDOWN() IIRC, which is similar to GLB's KEY(), so just use KEYDOWN() instead of KEY(). Of course you'll need to change SHOWSCREEN to FLIP or whatever it was (I can't remember now - haven't used Blitz in 10years). You never know - it might just work!
Tue, 02 Apr 2013, 12:31
dna
When using the instruction
delay 50
instead of
IF PRESS>0 THEN PRESS=PRESS-1

why does the delay instruction return two keypresses at times?

-=-=-
DNA
Tue, 02 Apr 2013, 19:39
dna
Here's what I came up with



Still gives the double bounce at times for some reason.

-=-=-
DNA
Wed, 03 Apr 2013, 10:56
steve_ancell
You do of course realise that Delay 200 will pause your program for 200 milliseconds, regardless of where in the program you implement it.
Wed, 03 Apr 2013, 11:54
dna
Yes but what I do not see is the logic behind the Speed variable.
I can see that it does not slow the program but its name suggests something to that effect.

** I'm guessing that the Press variable has something to do with slowing via machine cycles.

If so then that is an area that is not documented.

-=-=-
DNA
Wed, 03 Apr 2013, 12:44
rockford
"press" is just a variable counter. Every loop the program makes the counter will decrease by one. Once the press variable=0 a key can be pressed again or repeat an action if it is still pressed. Increase or decrease the "press=" value to speed up or slow down keypress delay.

As you stated, this doesn't slow your program down at all - everything else will still be running, without any pauses. The only thing being slowed is repetition of key being pressed.
Wed, 03 Apr 2013, 13:56
waroffice
I just came up with a slightly different version of your code.

this is my "checkkeys" function, runs once per loop