keydown for 2 keys

Blitz3D Forums/Blitz3D Beginners Area/keydown for 2 keys

how can you check if 2keys are pressed ie right and up arrows

i tried 'if keydown(200) and keydown(205) then ' but doesnt work

thanks

Thats how its done. But some keyboard combinations don't work on certain hardware. It isn't Blitz's fault.

you could try nesting them
i.e.

If Keydown(200) then
   If Keydown(205) then
     DoStuff()
   EndIf
Endif


not that I would do a control system for a game like this, but this works fine for me:
Graphics 640,480,0,2



Type Player
	Field Image
	Field X
	Field Y
End Type

Global p1.Player = New Player
	p1\X = 320
	p1\Y = 240
	p1\Image = CreateImage(32,32)
	SetBuffer ImageBuffer(p1\Image)
	Color 255,0,0
	Rect 0,0,32,32,1
	HandleImage p1\Image,16,16
	
	
SetBuffer BackBuffer()
	
While Not KeyDown(1) 



If KeyDown(200) Then
	p1\Y=p1\Y - 1
	If p1\Y < 0 Then p1\Y = 0
   If KeyDown(205) Then
     p1\X=p1\X + 1
	 If p1\X > 640 Then p1\X = 640
   EndIf
EndIf

If KeyDown(208) Then
	p1\Y=p1\Y + 1
	If p1\Y > 480 Then p1\Y = 480
   If KeyDown(203) Then
     p1\X=p1\X - 1
	 If p1\X < 0 Then p1\X = 0
   EndIf
EndIf

DrawImage p1\Image, p1\X, p1\Y

Flip
Cls

Wend

End


Doesnt work for me, man just goes up

ElseIf KeyDown(200) Then ;move up

If KeyHit(205) Then man\x =man\x +8
If KeyHit(203) Then man\x =man\x -8
blah blah

end if

Write a seperate program that only checks keys and prints the results to the screen. This will tell you if the problem is with your hardware or if it's with your code.

Note that KeyHIT commands can only be used ONCE. If you need to perform several checks on a KeyHIT command than store it into a variable first.
down_key = KeyHit(208)
If down_key = True Then ...
If down_key = True Then ...
If down_key = False Then ...


GJ,

just put the "If Keydown(200)....If Keydown(205)" in seperate If/Endif statements. Blitz is so fast that you can press two keys at the same time and it will process the commands "virtually" simultaneously. You won't even notice the difference. I do it all the time!

I don't see the reason why the seperate IF structure should help here. This is a OS issue as far as I know. It works on some systems, on some other systems it doesn't.