Page 1 of 1

keyboard pushy thingy?

Posted: Mon Jan 16, 2006 1:45 am
by Hrothgar
I'm having a slight problem with the inkey$ function. It works fine but when i hold down a key it kind of pushes it once initially then waits for a moment and THEN registers it as being held down. This is very annoying for having sprites that are controlled by keyboard input and looks really unproffessional.

How do I stop this?

Posted: Mon Jan 16, 2006 2:26 am
by Macric
see the way you put your code lines, if you do this,

Code: Select all

DO
thing$ = INKEY$
{codelines}'<---
LOOP UNTIL thing$ <> nothing$
it will need to read ALL the {codelines} unusefully, i would suggest to do this,

Code: Select all

DO
thing$ = INKEY$
LOOP UNTIL thing$ <> nothing$
{codelines}'<---
possibly this would solve your problem.[/code]

Posted: Mon Jan 16, 2006 3:25 am
by Guest
Nah thats not the problem. I was thinking more like sprites eg.

Code: Select all

screen 13, 16, 1, 1

dim bobx as integer
bobx = 1
do
thing$ = inkey$ 

if thing$ = " " then
    bobx = bobx + 1
    cls
end if

locate (bobx,1)
print "B"   'Bob the happy happy sprite
loop until thing$ = "x"
this code is just an example but say you want bob the happy sprite to move down on the screen when you push spacebar and for the program to end when you push "x" when you hold down the spacebar instead of bob just moving straight down he moves down one space then waits for about half a second and then starts moving down at a uniform rate.

Posted: Mon Jan 16, 2006 3:33 am
by Hrothgar
^^ that was me

I just noticed that it happens for everything to do with the keyboard. even in this forum. if you hold down a letter it types one of them, waits half a second then continues. How do I remove that delay from my programs?

Posted: Mon Jan 16, 2006 4:04 am
by Z!re
Hrothgar wrote:^^ that was me

I just noticed that it happens for everything to do with the keyboard. even in this forum. if you hold down a letter it types one of them, waits half a second then continues. How do I remove that delay from my programs?
You cant really..

It's how keyboard input works..

You can however use a KeyState routine, that only returns wheter a key is held down or not..

Try MULTIKEY()

Posted: Mon Jan 16, 2006 10:02 am
by Hrothgar
Multikey works perfectly, thanks z!re before you mentioned it I didn't know it existed. long live the power of freebasic.

Key thingy

Posted: Mon Jan 16, 2006 12:01 pm
by Zim
Are we talking about the typematic rate and delay here?

In DOS you use the MODE command to adjust that. In windows, there's a control panel item for that.

Posted: Sun Jan 22, 2006 2:14 am
by Michael Calkins
Are we talking about the typematic rate and delay here?
Yes.

In QBASIC (under DOS), it is possible to use INP() to read from the keyboard, I think, without effect fromt he typematic rate, etc.
http://www.network54.com/Forum/171757/m ... ey+presses..

However, it seems he is using FreeBASIC, and his problem has already been solved...
Regards,
Michael