Consoles - Newbie Alert

BlitzPlus Forums/BlitzPlus Beginners Area/Consoles - Newbie Alert

fixed ^_^

'ave phun

window=CreateWindow("Non-focus-loosing keys   - CS^TBL",0,0,550,280,0,1)
Global canvas=CreateCanvas(4,4,512,256,window)

SetBuffer CanvasBuffer(canvas)

Dim Keys(255)
Global Alt,Shift,Ctrl

Repeat
	WaitEvent()
	If EventID()=$803
		quit=True
	EndIf

	Readkeys()
	If Keys(37)
		;If Shift
		;If Ctrl
		If Alt
			x=x-7
		EndIf
		x=x-1
		If x<0 x=0
		Update(x)
	EndIf
	If Keys(39)
		;If Shift
		;If Ctrl
		If Alt
			x=x+7
		EndIf
		x=x+1
		If x>127 x=127
		Update(x)
	EndIf
	
Until quit
End

Function Update(x)
	SetBuffer CanvasBuffer(canvas)
		Cls
		Rect x*4,32,4,4,False
	FlipCanvas canvas
End Function

Function Readkeys()

	For t=0 To 15
		Keys(t)=0
		key=GetAsyncKeyState(t)
		If (key And 1)
			Keys(t)=1
		EndIf
	Next
	For t=19 To 255
		Keys(t)=0
		key=GetAsyncKeyState(t)
		If (key And 1)
			Keys(t)=1
		EndIf
	Next

	shiftkey=GetAsyncKeyState(16)
	If shiftkey=-32767 ; down
		Shift=1
	EndIf
	If Shift
		If shiftkey=1 ; up
			Shift=0
		EndIf
		If shiftkey=0 ; up
			Shift=0
		EndIf
	EndIf

	ctrlkey=GetAsyncKeyState(17)
	If ctrlkey=-32767 ; down
		Ctrl=1
	EndIf
	If Ctrl
		If ctrlkey=1 ; up
			Ctrl=0
		EndIf
		If ctrlkey=0 ; up
			Ctrl=0
		EndIf
	EndIf

	altkey=GetAsyncKeyState(18)
	If altkey=-32767 ; down
		Alt=1
	EndIf
	If Alt
		If altkey=1 ; up
			Alt=0
		EndIf
		If altkey=0 ; up
			Alt=0
		EndIf
	EndIf

End Function