modifier keys in fullscreen

BlitzMax Forums/BlitzMax Beginners Area/modifier keys in fullscreen

jkrankie(Posted 2011) [#1]
How do i tell if a modifier key is being held down? i need to add command+q quitting functionality on the mac version of one of my games, only i can't work out how to get it to work. keydown(modifier_command) doesn't seem to do anything...

Cheers
Charlie


Oddball(Posted 2011) [#2]
KEY_LSYS and KEY_RSYS are the command keys on Mac.


Perturbatio(Posted 2011) [#3]
Graphics 800, 600

While Not AppTerminate() And Not KeyDown(KEY_ESCAPE)
	PollEvent()
	If(CurrentEvent.id = EVENT_KEYDOWN)
		Local e:TEvent = PeekEvent()

		If (CurrentEvent.mods & MODIFIER_COMMAND) Then
		?MACOS
			Print "Command pressed"
		?Win32
			Print "Control pressed"
		?Linux
			Print "Control pressed"
		?
			
		EndIf		
		If (CurrentEvent.mods & MODIFIER_SHIFT) Then
			Print "Shift pressed"
		EndIf		
		If (CurrentEvent.mods & MODIFIER_ALT) Then
			Print "Alt pressed"
		EndIf
	EndIf
Wend

End


Last edited 2011


Oddball(Posted 2011) [#4]
Also AppTerminate() detects Command+Q when in windowed mode.


jkrankie(Posted 2011) [#5]
Excellent, thanks chaps!

Cheers
Charlie


jkrankie(Posted 2011) [#6]
Yeah, i noticed that. Also, If KeyDown(KEY_LSYS)And KeyHit(key_q) doesn't detect anything in windowed mode, presumably the os is catching that before blitz...

Cheers
Charlie