Hi i have a question. you know how when you hold a key, it delays for a second, and then repeats at a set timing? well, how do you make it so theres no delay?? i used to know this. i think it has something to do with an environment setting in dos, but is there a way to do it purely in qb? thanx :bounce:
This code snippet should work:
Code:
dim KeyPress as integer 'This does not have to be an array...
Do 'To initiate your loop
KeyPress = INP(&h60) 'I think its 60....haven't used it in a while
select case KeyPress
case <Hexidecimal code for key>
end select
loop until <Condition1> <math function)> <Condition2>
If that doesn't work, e-mail me!
Alex
dude thanx a lott!!!
I shyed away from using that a while ago cause it started messing up my comput and making the mouse act all random. screw it... its working now! thanx again
Its my job to help.....the only problem w/the code i gave you is when you press over 5 keys, it will start to beep when you press a key....it may just be my computer...i dunno
o well
Alex
hey check it out you can get rid of that beeping with this:
Code:
DEF SEG = 0: POKE &H41A, PEEK(&H41C): DEF SEG
and... unfortunately that code didnt hold up to my vigorous 8) testing... try this.
Code:
SCREEN 13
LOCATE 1, 1: PRINT "hit esc to quit"
DO
DEF SEG = 0: POKE &H41A, PEEK(&H41C): DEF SEG
Keyp = INP(&H60)
SELECT CASE Keyp
CASE 72
y = y - 1
CASE 75
x = x - 1
CASE 77
x = x + 1
CASE 80
y = y + 1
CASE 1
END
END SELECT
PSET (x, y)
FOR p = 1 TO 1000
NEXT
LOOP
just go all random and eventually itll hang up on you. (unless its just my computer)
why does everyone
think that?! lol well if someone else knows code where this wont happen please share, k?
Code:
DEF SEG = 0: POKE &H41A, PEEK(&H41C): DEF SEG
while that's cleaner,
clears the key buffer all the same. But your code, besides looking fine, works fine on my computer. &H60 (96), is how any program gets keys from the keybuffer without that handy keypress delay (thogh asm programs use an interrupt vector to get every key's status).
try downloading a program called 'multikey.bas' by the late milo sedlack. It's simple, uses assembly and I think you'll like it. If you're using any major qb library DQB, CosmoX, etc), all of those have a keyhandler. I dont know about UGL, but it might (and should).
i know the codes good... maybe it IS just my computer... like i run the prog, and move it all around random and (almost) evry time i turn it hangs for like 1/2 second and then keeps going.. i dont know why at all hey thanks for trying out my code on ur computer tho. i dunno my cpus all in compatibility mode paging so maybe that has somethin to do with it
If you use INP(&H60) be sure to do this:
Code:
FUNCTION neoKeybInkeyScan%
keyp% = INP(&H60)
IF keyp% < 128 THEN neoKeybInkeyScan% = keyp% ELSE neoKeybInkeyScan% = 0
END FUNCTION
Well, I tried that and it worked pretty much like the regular
... I inserted a
Code:
LOCATE 1, 30: PRINT Keyp
inside the main loop so I could see what was happening when it hung up after the turns, and every time it hangs up, Keyp becomes 0 for that amount of time; even when I'm clearly holdin the key. It makes NO SENSE!!! Am I the only one this happens to??
well, just out of curiosity, are you using windows xp or something that emulates dos?