keyboard pushy thingy?

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Hrothgar
Coder
Posts: 25
Joined: Tue Nov 22, 2005 8:32 pm
Location: Perth, Oz

keyboard pushy thingy?

Post by Hrothgar » Mon Jan 16, 2006 1:45 am

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?
Image
Towels may be harmful if swallowed in large quantities.

Macric
Coder
Posts: 34
Joined: Fri Mar 25, 2005 11:11 pm
Location: Mexico

Post by Macric » Mon Jan 16, 2006 2:26 am

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]

Guest

Post by Guest » Mon Jan 16, 2006 3:25 am

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.

Hrothgar
Coder
Posts: 25
Joined: Tue Nov 22, 2005 8:32 pm
Location: Perth, Oz

Post by Hrothgar » Mon Jan 16, 2006 3:33 am

^^ 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?
Image
Towels may be harmful if swallowed in large quantities.

Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re » Mon Jan 16, 2006 4:04 am

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()
I have left this dump.

Hrothgar
Coder
Posts: 25
Joined: Tue Nov 22, 2005 8:32 pm
Location: Perth, Oz

Post by Hrothgar » Mon Jan 16, 2006 10:02 am

Multikey works perfectly, thanks z!re before you mentioned it I didn't know it existed. long live the power of freebasic.
Image
Towels may be harmful if swallowed in large quantities.

User avatar
Zim
Veteran
Posts: 98
Joined: Mon Dec 05, 2005 4:31 pm
Location: Wisconsin, USA
Contact:

Key thingy

Post by Zim » Mon Jan 16, 2006 12:01 pm

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.
--- Zim ---
--- Time flies like an arrow, but fruit flies like a banana ---

User avatar
Michael Calkins
Veteran
Posts: 76
Joined: Tue Apr 05, 2005 8:40 pm
Location: Floresville, Texas
Contact:

Post by Michael Calkins » Sun Jan 22, 2006 2:14 am

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
Bring on the Maulotaurs! oops...
I like to slay Disciples of D'Sparil...

Post Reply