Keyboard Problem

Blitz3D Forums/Blitz3D Programming/Keyboard Problem

Paragon(Posted 2003) [#1]
I am experiencing a keyboard problem in a program I am working on.

The program uses a data structure containing the ASCII code for a particular key as well as its associated scan code. The program uses GetKey() to determine if a key has been pressed, then stores the assoicated scan code for processing the next time through the loop. Using KeyDown() and a couple timers, I am able to provide an auto-repeat feature for the UI portion of my program.

This method works great until, once in a while, the keyboard buffer either overflows (indicated by the motherboard's speaker emitting a beep) or comes close to overflowing. When this happens, KeyDown() continually returns true for the last scancode.

I wrote the code below to verify this. You'd need to be able to type quickly enough to overflow the keyboard buffer (or come close to overflowing it) while the program is running. You could also reduce the value in the call to CreateTimer().

Once the program is "stuck" (KeyDown returns true all the time), by deactivating and then reactivating the window in which it is running will un-jamb it.


timer = CreateTimer( 5 )

txt$ = ""
Repeat
Cls
down = False
For n = 1 To 88
If KeyDown( n ) Then down = True : Exit
Next
If down Then
txt$ = txt$ + n + " "
Text 0, 0, "Down: " + txt$
If Len( txt$ ) > 40 Then txt$ = ""
Else
Text 0, 0, "Up"
sc$ = ""
EndIf
WaitTimer timer
Until KeyHit( 1 )


I am wondering if this is a coding problem on my part, a bug in Blitz3D or possibly some other issue particular to my system.


Sunteam Software(Posted 2003) [#2]
It works fine here. I'd recommend you take a look at your keyboard settings both in Windows and in your BIOS. Could be related to key repeat/delay speeds.