Hello,
I am working on keyboard interface for my program. It works if I type at a slow to moderate speed, but If I type at my usual (lighing fast) speed, I get tons of missed strokes. Will someone please take a look at this code and tell me how I might be able to avoid the missed strokes. I have it inside a loop, because it will endup being a function in a game, so with that on top of this little bit of code, I imagine it may be even slower!
I've run this with and without sync, it makes no apparent change in speed.
set display mode 800,600,32
Co=RGB(240,255,35):ink co,1
dim inpt$(5)
keypress=0
i=1
tim=timer()
sync rate 60
sync on
do
cls
text 1,1,"text input:"+" inkey$()="+inkey$()+" keypress="+str$(keypress)+" len inpt$(i)="+str$(len(inpt$(i)))+" scancode="+str$(scancode())
`grab keystrokes
if inkey$()<>"" and keypress=0 and scancode()<>14
inpt$(i)=inpt$(i)+inkey$()
keypress=1
endif
`backspace
if scancode()=14 and len(inpt$(i))>0 and keypress=0 or scancode()=14 and len(inpt$(i))>0 and timer()>tim+75
inpt$(i)=left$(inpt$(i),len(inpt$(i))-1)
keypress=1
tim=timer()
endif
`reset
if keypress=1 and inkey$()=""
keypress=0
endif
if len(inpt$(i))>98
i=i+1
endif
for z=1 to 5
text 1,z*12,inpt$(z)
next z
if mouseclick()=1
end
endif
sync
loop
Thanks for any help!!!
D