scancode capture

Blitz3D Forums/Blitz3D Beginners Area/scancode capture

is there a way, i should say a quick and easy way to capture blitz's scancodes, i know i could build a function that tests to see that if each and every key is pressed return the appropriate scancode, but that is kinda clunky, i was just wondering if there is a way to capture this elusive scancode.

just make my job of setting user defined keys a whole lot easier than checking for each and every key other that the ascii keys.....eg the cursor keys

The only thing I could come up with is this:
	;TEST
	
	;add left/right arrow
	AddKey(203)
	AddKey(205)
	
	;add Esc (for exit)
	AddKey(1)
	
	Repeat

		;read keys
		ok = GetSKey()
		
		;print scancode if found key
		If ok <> 0 Then Print ok
		
		
	Until (ok = 1)
	
	End
	
;scankey type
Type SKey
	Field v
End Type

;add scancode to list
Function AddKey(scancode)
	s.SKey = New SKey
	s\v = scancode
End Function

;scan codes in list
Function GetSKey()
	For s.SKey = Each SKey
	If KeyDown(s\v) Then Return s\v
	Next
End Function

That way you'll only scan the keys that you need, instead of all of them (0..255)

That's pretty slick.