how to check alt is held down as a modifier?

BlitzMax Forums/BlitzMax Programming/how to check alt is held down as a modifier?

Robert Cummings(Posted 2006) [#1]
I tried keydown(KEY_LALT) etc but it does not behave like a modifier, in fact I only need to press it once at any time and it behaves as though it's perminantly pressed.


Dreamora(Posted 2006) [#2]
There are 2 ways:

Using the polled input stuff like keydown:
You need to set a variable that tells that the modifier is held down. This variable then needs to be set to false if the key is not down anymore.


Using event based handling:

SetHotKeyEvent(key,modifier,event,owner)
With that you can check for mods through eventid and the like. (you must use the modifier_ .. constants for the modifier)


Robert Cummings(Posted 2006) [#3]
uh, confusing for a simple key that should work with keydown() no?

The reason for this is because I am supporting alt + enter for fullscreen etc


Perturbatio(Posted 2006) [#4]
Graphics 640,480,0
Global depth = 0

While Not KeyDown(KEY_ESCAPE)

Flip
If KeyDown(KEY_LALT) And KeyDown(KEY_ENTER)
	If depth = 0 Then depth = 32 Else depth = 0
	Graphics 640,480,depth
EndIf

Wend
End

*EDIT*
I really should read before posting more. that's not as a modifier (obviously)


Dreamora(Posted 2006) [#5]
hmm not understand your problem ...
Could you be a little more specific why the keydown should not work? (beside using gadgets etc in which case you could use the EVENT_KEYDOWN etc instead of keydown?)


Robert Cummings(Posted 2006) [#6]
the problem is the status of keydown(KEY_LALT) stays down...


Dreamora(Posted 2006) [#7]
Did you modify any of the modules or something?
If not, then its definitely a bug with your keyboard / keyboard driver, as it behaves on my system as it should. ie keydown only reports 1 on key_lalt when the key is actually pressed.

Or do you have some EventHook that might interfere with the input event hook and the like? (like an eventhook that checks for the alt key and then returns null instead of data?!)


TomToad(Posted 2006) [#8]
KeyDown(KEY_LALT) returns 1 when held down and 0 when released on my system. Even tried pressing it with different keys and got the same result. Are you sure that sticky keys aren't enabled in Windows on your system? Assuming you're talking about a Windows system. :)


Robert Cummings(Posted 2006) [#9]
Thanks for your answers, I will investigate.


Robert Cummings(Posted 2006) [#10]
Ok here goes:

http://www.blitzmax.com/Community/posts.php?topic=58907

I reported it as a bug as I believe it is a bug - more info in the link above.