KeyDown problem

Blitz3D Forums/Blitz3D Programming/KeyDown problem

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

You need to use Flushkeys when you want to use KeyHit or Inkey. If you decide to use KeyDown, you can do something like this:

; submenu
while not keydown(1)
; gfx etc
wend

while keydown(1) ; wait until the user releases the key
 delay 1
wend

;mainmenu
while not keydown(1)
; gfx etc.
wend


of course, it may be a better idea to use a function, somethin like
function waitNoaction()
 action=0
 repeat
  for i=0 to 255
   if keydown(i)=1 then 
    action=1
    exit
   endif
  next
  if mousedown(1)then action=1
  if mousedown(2)then action=1
 until action=0
end function


But like the first example this is a OnMouseUp thing. If you want the exit condition on MouseDown, you need to use a flag variable, something like:

; submenu
while not keydown(1)
 ;..
wend

key1=1

; menu2
while (keydown(1)=0) or (key1=1)
 if keydown(1)=0 then key1=0
 ;...
wend