Scancode problem

Blitz3D Forums/Blitz3D Beginners Area/Scancode problem

Nicstt(Posted 2006) [#1]
the following code checks through scancodes for specific key hits, it should also differentiate between capitals and normal

For lettx.text_letter = Each text_letter
If KeyDown(42) = False And KeyDown(54) = False
If (KeyHit(lettx\scancode) = True And Len(lettx\symbol$) = 1)
Notify lettx\symbol$
EndIf
ElseIf KeyDown(42) = True Or KeyDown(54) = True
If (KeyHit(lettx\scancode) = True And Len(lettx\caps_symbol$) = 1)
Notify lettx\caps_symbol$
EndIf
EndIf
Next

when first running, when i press a letter i get lowercase as expected. holding down shift gets capital letters.

However, once i release the shift key i still get capitals (no caps lock isnt on).

Any suggestions?


Matty(Posted 2006) [#2]
Seems to be something with 'notify' as if I modify your code to this it works:

Graphics 800,600,32,2
SetBuffer FrontBuffer()
Repeat

If KeyDown(42) = False And KeyDown(54) = False
	If (KeyHit(30) = True And Len("a") = 1)
		Text 0,i, "a"
		i=i+15
	EndIf
ElseIf KeyDown(42) = True Or KeyDown(54) = True
		If (KeyHit(30) = True And Len("A") = 1)
			Text 0,i, "A"
			i=i+15
		EndIf
	 
EndIf
Flip
Until KeyDown(1)
End



Nicstt(Posted 2006) [#3]
Thx for reply Matty.

I inserted flushkeys() after the notify command, must be something to do with the repeat key function that kicks in when holding keys down, most curious - and irritating. Notify does have an affect though.

although it works fine without flushkeys in both b3d and b+ when using text


octothorpe(Posted 2006) [#4]
My guess is that Notify grabs focus and your program doesn't get the KeyUp events on the shift keys.